aboutsummaryrefslogtreecommitdiff
path: root/contests/filtrationContest/A/main.cpp
blob: 5968cb287b8904c601204ef2f8890fafe49628d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include<bits/stdc++.h>

using namespace std;

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tt;
	cin >> tt;
	while(tt--){
    int n;
    cin >> n;
    string s;
    cin >> s;
    bool sus = false;
    for (int i = 0; i < n - 1; i++) {
      if(s[i] == s[i + 1]) {
        s[i] = '.';
      }
    }
    map<int, int> fq;
    for (auto ch : s) {
      fq[ch]++;
    }
    for (auto [key, val] : fq) {
      if (val > 1 && key != '.') {
        sus = true;
        break;
      }
    }
    cout << (!sus ? "YES" : "NO") << '\n';
	}
}