-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck.cpp
More file actions
104 lines (82 loc) · 2.42 KB
/
check.cpp
File metadata and controls
104 lines (82 loc) · 2.42 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;
long long type;
long long a, b, c;
pair<bool, long long> readAnswer(InStream &in) {
string s = lowerCase(in.readString("[a-zA-Z]{2,3}"));
if (s != "yes" && s != "no") {
in.quitf(_pe, "Answer isn't either Yes or No");
}
if (s == "no") {
return {0, 0};
} else if (s != "yes") {
in.quitf(_wa, "Wrong yes/no string");
}
long long ans = in.readLong();
if (type == 0) {
return {true, ans};
}
vector<long long> now = {a, b, c};
for (int i = 0; i < ans; i++) {
long long x = in.readLong();
long long y = in.readLong();
vector<bool> used(3);
for (int j = 0; j < 3; j++) {
if (used[j])
continue;
if (now[j] == x) {
used[j] = true;
now[j]++;
break;
}
}
if (accumulate(used.begin(), used.end(), 0) != 1) {
in.quitf(_wa, "Left point doesn't exist");
}
for (int j = 0; j < 3; j++) {
if (used[j])
continue;
if (now[j] == y) {
used[j] = true;
now[j]--;
break;
}
}
if (accumulate(used.begin(), used.end(), 0) != 2) {
in.quitf(_wa, "Right point doesn't exist");
}
}
if (now[0] != now[1] || now[0] != now[2]) {
in.quitf(_wa, "Points aren't in the same place");
}
return {true, ans};
}
int main(int argc, char *argv[]) {
registerTestlibCmd(argc, argv);
type = inf.readInt();
a = inf.readLong();
b = inf.readLong();
c = inf.readLong();
auto A = readAnswer(ans);
auto B = readAnswer(ouf);
long long jans = A.second;
long long pans = B.second;
if (type == 0) {
if (A != B) {
quitf(_wa, "Participant answer is different from jury");
}
} else {
if (A.first < B.first) {
quitf(_fail, "Participant found better answer that jury");
} else if (A.first > B.first) {
quitf(_wa, "Jury found better answer than participant");
}
if (jans < pans) {
quitf(_wa, "Jury found better answer than participant");
} else if (jans > pans) {
quitf(_fail, "Participant found better answer that jury");
}
}
quitf(_ok, "%lld", pans);
}