-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlg1042.cpp
50 lines (43 loc) · 1.08 KB
/
lg1042.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
#include <vector>
#include <string>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
vector<string> ans11, ans21;
void a11(int &x, int &y, bool win) {
if (win) ++x; else ++y;
int mn = min(x, y), mx = max(x, y);
if (mx>=11 && mx-mn>=2) {
ans11.push_back(to_string(x) + ":" + to_string(y));
x = y = 0;
}
}
void a21(int &x, int &y, bool win) {
if (win) ++x; else ++y;
int mn = min(x, y), mx = max(x, y);
if (mx>=21 && mx-mn>=2) {
ans21.push_back(to_string(x) + ":" + to_string(y));
x = y = 0;
}
}
int main() {
char c;
int x=0, y=0, x1=0, y1=0;
while (scanf("%c", &c)!=EOF) {
if (!isalpha(c)) continue;
if (c=='E') {
ans11.push_back(to_string(x) + ":" + to_string(y));
ans21.push_back(to_string(x1) + ":" + to_string(y1));
break;
}
a11(x, y, c=='W');
a21(x1, y1, c=='W');
}
for (auto s : ans11)
cout << s << '\n';
cout << '\n';
for (auto s : ans21)
cout << s << '\n';
return 0;
}