Submission #711791

#TimeUsernameProblemLanguageResultExecution timeMemory
711791LuicosasChecker (COCI19_checker)C++17
110 / 110
107 ms4724 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back #define sz(x) (int)(x.size()) #define itr(x) x.begin(), x.end() #define prv(x) for(auto& i : x) cout << i << " "; cout << "\n"; #ifdef LOCAL #define debug(...) cerr << #__VA_ARGS__ << " : "; for(auto& i : {__VA_ARGS__}) cerr << i << " "; cerr << "\n"; #else #define debug(...) #endif int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, t; cin >> t >> n; string s; cin >> s; vector<array<int,2>> nxt(n); for(int i = 0; i < n; i++) { nxt[i] = {(i + 1) % n, s[i] - '0'}; } vector<array<int,3>> E(n - 3); for(int i = 0; i < n - 3; i++) { cin >> E[i][0] >> E[i][1] >> E[i][2]; E[i][0]--; E[i][1]--; if((E[i][1] - E[i][0] + n) % n > (E[i][0] - E[i][1] + n) % n){ swap(E[i][0], E[i][1]); } } sort(itr(E), [&](auto& a, auto& b) { return (a[1] - a[0] + n) % n < (b[1] - b[0] + n) % n; }); int triged = 1, colored = 1; for(auto& e : E) { if(nxt[e[0]][0] == -1 || nxt[nxt[e[0]][0]][0] != e[1]) { triged = 0; break; } if(e[2] ^ nxt[e[0]][1] ^ nxt[nxt[e[0]][0]][1]) { colored = 0; } nxt[nxt[e[0]][0]] = {-1, 0}; nxt[e[0]] = {e[1], e[2]}; } int xr = 0; for(int i = 0; i < n; i++) { xr ^= nxt[i][1]; } colored &= (xr == 0); if(!triged) { cout << "neispravna triangulacija\n"; } else if(!colored) { cout << "neispravno bojenje\n"; } else { cout << "tocno\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...