-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCF Round 734 Div 3 - Wonderful Coloring (B1).cpp
69 lines (62 loc) · 1.52 KB
/
CF Round 734 Div 3 - Wonderful Coloring (B1).cpp
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Problem Link: https://codeforces.com/contest/1551/problem/B1
#include<iostream>
#include<limits.h>
#include<math.h>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define modulo 1000000007
#define mp make_pair
#define pb push_back
int main()
{
ll tests;
cin >> tests;
while(tests--)
{
string str;
cin >> str;
sort(begin(str),end(str));
//unordered_set<char> red, green;
int count = 0;
bool flag = true;
for(int i = 0; i < str.length();)
{
if(i+1 < str.length() && str[i+1] == str[i])
{
count++;
// red.insert(str[i]);
// green.insert(str[i]);
int temp = i+2;
while(temp < str.length() && str[temp] == str[i]) {temp++;}
i = temp;
}
else if(flag)
{
count++;
//red.insert(str[i]);
flag = false;
i++;
}
else if(!flag)
{
//green.insert(str[i]);
flag = true;
i++;
}
}
if(!flag) {count--;}
cout << count;
cout << "\n";
}
return 0;
}