This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,popcnt,sse4,abm")
#include <bits/stdc++.h>
using namespace std;
#ifdef WAIMAI
#define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE)
void dout() {cout << '\n';}
template<typename T, typename...U>
void dout(T t, U...u) {cout << t << (sizeof... (u) ? ", " : ""), dout (u...);}
#else
#define debug(...) 7122
#endif
#define ll long long
#define Waimai ios::sync_with_stdio(false), cin.tie(0)
#define FOR(x,a,b) for (int x = a, I = b; x <= I; x++)
#define pb emplace_back
#define F first
#define S second
const int SIZE = 2e5 + 5;
int subtask, n, ans = 2;
vector<int> adj[SIZE];
unordered_map<int, int> mp[SIZE];
void solve() {
cin >> subtask >> n;
string s;
cin >> s, s = " " + s;
FOR (i, 1, n - 1) {
adj[i].pb(i + 1);
mp[i][i + 1] = s[i] - '0';
}
adj[1].pb(n);
mp[1][n] = s[n] - '0';
FOR (i, 1, n - 3) {
int a, b, c;
cin >> a >> b >> c;
if (a > b) swap(a, b);
adj[a].pb(b);
mp[a][b] = c;
}
FOR (i, 1, n) sort(adj[i].begin(), adj[i].end());
FOR (i, 1, n) {
for (int j = 0; j + 1 < adj[i].size(); j++) {
int a = i, b = adj[i][j], c = adj[i][j + 1];
if (!mp[b].count(c)) {
ans = min(ans, 0);
break;
}
int c1 = mp[a][b], c2 = mp[a][c], c3 = mp[b][c];
if ((c1 ^ c2 ^ c3) != 0) ans = min(ans, 1);
}
}
cout << (ans == 0 ? "neispravna triangulacija" : ans == 1 ? "neispravno bojenje" : "tocno") << '\n';
}
int main() {
Waimai;
solve();
}
Compilation message (stderr)
checker.cpp: In function 'void solve()':
checker.cpp:49:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | for (int j = 0; j + 1 < adj[i].size(); j++) {
| ~~~~~~^~~~~~~~~~~~~~~
# | 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... |