-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy path979B. Treasure Hunt.cpp
61 lines (49 loc) · 1.07 KB
/
979B. Treasure Hunt.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 <bits/stdc++.h>
using namespace std;
int n;
long long fr[3][60];
string a, b, c;
int main() {
cin >> n;
cin >> a >> b >> c;
for(int i = 0; i < a.length(); ++i) {
if(islower(a[i]))
++fr[0][a[i] - 'a'];
else
++fr[0][a[i] - 'A' + 26];
}
for(int i = 0; i < a.length(); ++i) {
if(islower(b[i]))
++fr[1][b[i] - 'a'];
else
++fr[1][b[i] - 'A' + 26];
}
for(int i = 0; i < a.length(); ++i) {
if(islower(c[i]))
++fr[2][c[i] - 'a'];
else
++fr[2][c[i] - 'A' + 26];
}
long long mx[3] = {0};
for(int i = 0; i < 3; ++i) {
for(int j = 0; j < 60; ++j)
mx[i] = max(mx[i], fr[i][j]);
if(mx[i] == a.length()) {
if(n == 1)
mx[i] -= 1;
continue;
}
mx[i] += n;
if(mx[i] > a.length())
mx[i] = a.length();
}
if(mx[0] > mx[1] && mx[0] > mx[2])
cout << "Kuro" << endl;
else if(mx[1] > mx[0] && mx[1] > mx[2])
cout << "Shiro" << endl;
else if(mx[2] > mx[0] && mx[2] > mx[1])
cout << "Katie" << endl;
else
cout << "Draw" << endl;
return 0;
}