Submission #712017

#TimeUsernameProblemLanguageResultExecution timeMemory
712017pccChecker (COCI19_checker)C++14
0 / 110
300 ms108664 KiB
#include <bits/stdc++.h> using namespace std; #define pii pair<int,int> #define fs first #define sc second struct node{ set<pii> st; int pre,nxt; bool del; node(){ pre = nxt = 0; del = false; } void add(int to,int c){ st.insert({to,c}); } int get(int k){ auto it = st.upper_bound(make_pair(k,-1)); if(it == st.end()||it->fs != k)return 0; return it->sc; } }; const int mxn = 2e5+10; node v[mxn]; void remov(int k){ v[v[k].pre].nxt = v[k].nxt; v[v[k].nxt].pre = v[k].pre; v[k].del = true; return; } bool dif(int a,int b,int c){ if(!a||!b||!c)return 0; if(a == b||c == b||a == c)return 0; return 1; } int pos[mxn]; vector<pii> edges; int n; bool cmp(pii a,pii b){ int l1 = min(a.sc-a.fs,n-(a.sc-a.fs)); int l2 = min(b.sc-b.fs,n-(b.sc-b.fs)); return l1<l2; } int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>n>>n; string col; cin>>col; for(int i = 1;i<n;i++){ v[i].add(i+1,col[i-1]-'0'); v[i+1].add(i,col[i-1]-'0'); } v[n].add(1,col.back()-'0'); v[1].add(n,col.back()-'0'); for(int i = 0;i<n-3;i++){ int a,b,c; cin>>a>>b>>c; edges.push_back({min(a,b),max(a,b)}); v[a].add(b,c); v[b].add(a,c); } for(int i = 1;i<=n;i++)v[i].pre = i-1; for(int i = n-1;i>=1;i--)v[i].nxt = i+1; v[1].pre = n; v[n].nxt = 1; sort(edges.begin(),edges.end(),cmp); bool flag = true; for(auto &i:edges){ int a = i.fs,b = i.sc; if(v[a].del||v[b].del){ assert(false); cout<<"neispravna triangulacija\n"; return 0; } if(!dif(v[b].get(v[b].pre),v[b].get(a),v[a].get(v[b].pre))){ flag = false; } if(v[v[b].pre].pre == a){ remov(v[b].pre); } else{ assert(false); cout<<"neispravna triangulacija\n"; return 0; } } if(flag){ cout<<"tocno\n"; } else cout<<"neispravno bojenje\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...