Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std ;
- #define sz(s) int(s.size())
- typedef long long ll ;
- void ABDEL3AL () {
- ios_base::sync_with_stdio(false); cin.tie(nullptr) , cout.tie(nullptr) ;
- #ifndef ONLINE_JUDGE
- freopen("input.txt" , "r" , stdin) , freopen("output.txt" , "w" , stdout) ;
- #endif
- }
- int main() {
- ABDEL3AL() ;
- int t ; cin >> t ;
- while (t--) {
- int n;
- cin >> n;
- string s;
- cin >> s;
- bool vis[26], var = true;
- for (int i = 0; i < sz(s); i++) {
- if (vis[s[i] - 'A']) var = false ;
- if (s[i] != s[i + 1]) vis[s[i] - 'A'] = true ;
- }
- cout << (var ? "YES" : "NO") << "\n" ;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment