-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGarland.cpp
61 lines (49 loc) · 1.01 KB
/
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
56
57
58
59
60
61
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t,i,j,k,l;
t=1;
cin>>t;
while(t--)
{
string str;
cin>>str;
map<ll,ll>mp;
ll sz=0;
for(i=0;i<4;i++)
{
mp[str[i]-'0']++;
// sz=max(sz,mp[str[i]-'0']);
}
sz=mp.size();
l=4;
if(sz==3||sz==4)
{
cout<<l<<'\n';
continue;
}
if(sz==1)
{
cout<<"-1"<<'\n';
continue;
}
ll ps=4;
for(auto aol:mp)
{
ll pp=aol.second;
if(pp==3)
ps=6;
}
cout<<ps<<'\n';
}
return 0;
}