Source Code
#include <bits/stdc++.h>
using namespace std;
#define len(s) (int)s.size()
#define all(a) a.begin() , a.end()
#define int  long long
#define endl '\n'
#define MOD 1000000007
int min(int a, int b) { return (a < b) ? a : b; }
int max(int a,int b) { return (a > b) ? a : b; }
void solve() {
    string str;
    cin >> str;
    sort(all(str));
    int n = str.size() ;
    for(int i =1 ; i < n ; i++){
        if(str[i] != str[i-1] + 1 || str[i] > 'M' ){
            cout << "No" ;
            return;
        }
    }
    cout << "Yes";
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int T = 1;
    cin >> T;
    while (T--) {
        solve();
        cout << endl;
    }
}
Copy
Well-indexed? saifomar
GNU G++17
8 ms
596 KB
Accepted