-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGarland.cpp
More file actions
40 lines (34 loc) · 782 Bytes
/
Copy pathGarland.cpp
File metadata and controls
40 lines (34 loc) · 782 Bytes
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
// https://codeforces.com/problemset/problem/1809/A
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <string>
#include <bits/stdc++.h>
#include <cstdint>
#define ll long long
#define u64 uint64_t
#define i64 int64_t
using namespace std;
int main() {
int nC = 0;
cin >> nC;
for (int c = 0; c < nC; c++) {
int clrs[10] = {0};
string input;
cin >> input;
for (int i = 0; i < input.size(); i++) {
clrs[input[i]-'0']++;
}
int distr[5] = {0};
for (int clr : clrs)
distr[clr]++;
if (distr[3] == 1)
cout << "6\n";
else if (distr[4] == 1)
cout << "-1\n";
else
cout << "4\n";
}
return 0;
}