Source Code
#include <bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define endl '\n'

int main() {
    fast
    ll t;
    cin >> t;
    while(t--){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        bool ok = 1;
        if(s[0] == 'A'){
            for(ll i = 0; i < (ll) s.length() - 1 && ok; i++)
                if(s[i + 1] - s[i] != 1)
                    ok = 0;
            cout << (ok ? "YES" : "NO") << endl;
        }
        else
            cout << "NO" << endl;
    }
}
Copy
Well-indexed? Mohammad
GNU G++17
4 ms
392 KB
Accepted