# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
227320 | abeker | Checker (COCI19_checker) | C++17 | 1071 ms | 76000 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef pair <int, int> pii;
const int MAXN = 2e5 + 5;
int N;
char sides[MAXN];
vector <pii> adj[MAXN];
map <pii, int> clr;
void add_edge(int a, int b, int c) {
adj[a].push_back({b, c});
adj[b].push_back({a, c});
clr[{a, b}] = clr[{b, a}] = c;
}
void load() {
scanf("%*d%d%s", &N, sides);
for (int i = 0; i < N; i++)
add_edge(i, (i + 1) % N, sides[i] - '0');
for (int i = 0; i < N - 3; i++) {
int x, y, c;
scanf("%d%d%d", &x, &y, &c);
add_edge(--x, --y, c);
}
}
void solve() {
bool coloring = true;
for (int i = 0; i < N; i++) {
sort(adj[i].begin(), adj[i].end());
auto it = lower_bound(adj[i].begin(), adj[i].end(), pii(i, 0));
if (it == adj[i].end())
it = adj[i].begin();
rotate(adj[i].begin(), it, adj[i].end());
for (int j = 1; j < adj[i].size(); j++) {
pii x = adj[i][j - 1], y = adj[i][j];
int tmp = clr[{x.first, y.first}];
if (!tmp) {
puts("neispravna triangulacija");
return;
}
coloring &= tmp != x.second && tmp != y.second && x.second != y.second;
}
}
puts(coloring ? "tocno" : "neispravno bojenje");
}
int main() {
load();
solve();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |