# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
517313 |
2022-01-23T02:30:58 Z |
KoD |
Checker (COCI19_checker) |
C++17 |
|
495 ms |
31088 KB |
#include <bits/stdc++.h>
using std::vector;
using std::array;
using std::pair;
using std::tuple;
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int N;
std::cin >> N >> N;
std::map<pair<int, int>, int> col;
vector<int> next(N), prev(N);
for (int i = 0; i < N; ++i) {
next[i] = i + 1 == N ? 0 : i + 1;
prev[i] = i == 0 ? N - 1 : i - 1;
char c;
std::cin >> c;
col.emplace(std::minmax(i, next[i]), c - '0');
}
vector<int> deg(N, 2);
for (int i = 0; i < N - 3; ++i) {
int u, v, c;
std::cin >> u >> v >> c;
u -= 1, v -= 1;
deg[u] += 1, deg[v] += 1;
col.emplace(std::minmax(u, v), c);
}
const auto get_col = [&](const int u, const int v) {
auto itr = col.find(std::minmax(u, v));
return itr == col.end() ? 0 : itr->second;
};
std::queue<int> que;
for (int i = 0; i < N; ++i) {
if (deg[i] == 2) {
que.push(i);
}
}
bool triangle = true, color = true;
while (!que.empty()) {
int u = que.front();
que.pop();
if (deg[u] != 2) {
continue;
}
const int v = prev[u], w = next[u];
const int a = get_col(u, v), b = get_col(v, w), c = get_col(w, u);
if (a == 0 or b == 0 or c == 0) {
triangle = false;
break;
}
if ((a - b) * (b - c) * (c - a) == 0 or a + b + c != 6) {
color = false;
}
next[v] = w, prev[w] = v;
deg[v] -= 1, deg[w] -= 1;
if (deg[v] == 2) {
que.push(v);
}
if (deg[w] == 2) {
que.push(w);
}
}
if (!triangle) {
std::cout << "neispravna triangulacija\n";
} else if (!color) {
std::cout << "neispravno bojenje\n";
} else {
std::cout << "tocno\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
2 ms |
676 KB |
Output is correct |
9 |
Correct |
2 ms |
592 KB |
Output is correct |
10 |
Correct |
1 ms |
584 KB |
Output is correct |
11 |
Correct |
2 ms |
524 KB |
Output is correct |
12 |
Correct |
2 ms |
592 KB |
Output is correct |
13 |
Correct |
3 ms |
560 KB |
Output is correct |
14 |
Correct |
2 ms |
592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
472 ms |
30968 KB |
Output is correct |
2 |
Correct |
468 ms |
31036 KB |
Output is correct |
3 |
Correct |
390 ms |
30956 KB |
Output is correct |
4 |
Correct |
296 ms |
30996 KB |
Output is correct |
5 |
Correct |
314 ms |
30992 KB |
Output is correct |
6 |
Correct |
357 ms |
30940 KB |
Output is correct |
7 |
Correct |
320 ms |
30832 KB |
Output is correct |
8 |
Correct |
249 ms |
30776 KB |
Output is correct |
9 |
Correct |
230 ms |
30744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
495 ms |
30996 KB |
Output is correct |
2 |
Correct |
481 ms |
31016 KB |
Output is correct |
3 |
Correct |
459 ms |
31036 KB |
Output is correct |
4 |
Correct |
474 ms |
30960 KB |
Output is correct |
5 |
Correct |
478 ms |
31088 KB |
Output is correct |
6 |
Correct |
345 ms |
30784 KB |
Output is correct |
7 |
Correct |
334 ms |
30744 KB |
Output is correct |
8 |
Correct |
355 ms |
30928 KB |
Output is correct |
9 |
Correct |
319 ms |
30828 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
2 ms |
676 KB |
Output is correct |
9 |
Correct |
2 ms |
592 KB |
Output is correct |
10 |
Correct |
1 ms |
584 KB |
Output is correct |
11 |
Correct |
2 ms |
524 KB |
Output is correct |
12 |
Correct |
2 ms |
592 KB |
Output is correct |
13 |
Correct |
3 ms |
560 KB |
Output is correct |
14 |
Correct |
2 ms |
592 KB |
Output is correct |
15 |
Correct |
472 ms |
30968 KB |
Output is correct |
16 |
Correct |
468 ms |
31036 KB |
Output is correct |
17 |
Correct |
390 ms |
30956 KB |
Output is correct |
18 |
Correct |
296 ms |
30996 KB |
Output is correct |
19 |
Correct |
314 ms |
30992 KB |
Output is correct |
20 |
Correct |
357 ms |
30940 KB |
Output is correct |
21 |
Correct |
320 ms |
30832 KB |
Output is correct |
22 |
Correct |
249 ms |
30776 KB |
Output is correct |
23 |
Correct |
230 ms |
30744 KB |
Output is correct |
24 |
Correct |
495 ms |
30996 KB |
Output is correct |
25 |
Correct |
481 ms |
31016 KB |
Output is correct |
26 |
Correct |
459 ms |
31036 KB |
Output is correct |
27 |
Correct |
474 ms |
30960 KB |
Output is correct |
28 |
Correct |
478 ms |
31088 KB |
Output is correct |
29 |
Correct |
345 ms |
30784 KB |
Output is correct |
30 |
Correct |
334 ms |
30744 KB |
Output is correct |
31 |
Correct |
355 ms |
30928 KB |
Output is correct |
32 |
Correct |
319 ms |
30828 KB |
Output is correct |
33 |
Correct |
471 ms |
30928 KB |
Output is correct |
34 |
Correct |
472 ms |
30940 KB |
Output is correct |
35 |
Correct |
413 ms |
31024 KB |
Output is correct |
36 |
Correct |
297 ms |
30916 KB |
Output is correct |
37 |
Correct |
461 ms |
31028 KB |
Output is correct |
38 |
Correct |
465 ms |
30964 KB |
Output is correct |
39 |
Correct |
457 ms |
30920 KB |
Output is correct |
40 |
Correct |
336 ms |
30740 KB |
Output is correct |
41 |
Correct |
321 ms |
30828 KB |
Output is correct |
42 |
Correct |
247 ms |
30752 KB |
Output is correct |
43 |
Correct |
340 ms |
30912 KB |
Output is correct |