-
Notifications
You must be signed in to change notification settings - Fork 0
/
A_Garland.cpp
55 lines (54 loc) · 930 Bytes
/
A_Garland.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
// Jai shree ram
#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
string s;
cin >> s;
map<char, int> mp;
int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
for (int i = 0; i < 4; i++)
{
mp[s[i]]++;
}
if (mp.size() == 4)
{
cout << 4 << '\n';
return;
}
else if (mp.size() == 3)
{
cout << 4 << '\n';
return;
}
else if (mp.size() == 1)
{
cout << -1 << '\n';
return;
}
else
{
for(auto it:mp)
{
if(it.second==2)
{
cout << 4 << '\n';
return;
}
}
cout << 6 << '\n';
return;
}
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while (t--)
{
solve();
}
}