MohamedAbdel3al

A. Do Not Be Distracted!

Sep 9th, 2021 (edited)
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std ;
  4. #define sz(s) int(s.size())
  5. typedef long long ll ;
  6.  
  7.  
  8. void ABDEL3AL () {
  9. ios_base::sync_with_stdio(false); cin.tie(nullptr) , cout.tie(nullptr) ;
  10. #ifndef ONLINE_JUDGE
  11. freopen("input.txt" , "r" , stdin) , freopen("output.txt" , "w" , stdout) ;
  12. #endif
  13.  
  14. }
  15.  
  16. int main() {
  17. ABDEL3AL() ;
  18. int t ; cin >> t ;
  19. while (t--) {
  20. int n;
  21. cin >> n;
  22. string s;
  23. cin >> s;
  24. bool vis[26], var = true;
  25. for (int i = 0; i < sz(s); i++) {
  26. if (vis[s[i] - 'A']) var = false ;
  27. if (s[i] != s[i + 1]) vis[s[i] - 'A'] = true ;
  28. }
  29. cout << (var ? "YES" : "NO") << "\n" ;
  30. }
  31.  
  32. return 0;
  33. }
  34.  
Add Comment
Please, Sign In to add comment