Submission #1013121

#TimeUsernameProblemLanguageResultExecution timeMemory
1013121vjudge1Checker (COCI19_checker)C++17
0 / 110
3073 ms45016 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int const N=2e5+5; int const mod=1e9+7; int bk[N],fr[N]; int n; map<pair<int,int>,int> mp; bool check1(){ for(int i=1;i<n;i++) if(fr[i+1]+1>bk[i]) return 0; if(fr[1]+1>bk[n]) return 0; return 1; } bool is(int a,int b){ if(mp.find({a,b})!=mp.end()) return 1; return 0; } bool diff(int a,int b,int c){ if(mp[{a,b}]!=mp[{b,c}] && mp[{b,c}]!=mp[{c,a}]) return 1; return 0; } bool check2(){ vector<int> v1,v2; for (int i = 1; i <=n; ++i) v1.push_back(i); while(v1.size()>2){ int sz=v1.size(); if(is(v1[sz-1],v1[1])){ if(diff(v1[sz-1],v1[0],v1[1])==0) return 0; } else v2.push_back(v1[0]); for(int i=1;i<sz-1;i++){ if(is(v1[i-1],v1[i+1])){ if(diff(v1[i-1],v1[i],v1[i+1])==0) return 0; } else v2.push_back(v1[i]); } if(is(v1[sz-2],v1[0])){ if(diff(v1[sz-2],v1[sz-1],v1[0])==0) return 0; } else v2.push_back(v1[sz-1]); v1=v2; // for(int i:v1) // cout<<i<<' '; // cout<<endl; v2.clear(); } return 1; } int main(){ int t; cin>>t; cin>>n; string col; cin>>col; for(int i=0;i<n-1;i++) mp[{i+1,i+2}]=col[i]-'0'; mp[{n,1}]=col[n-1]-'0'; for(int i=1;i<=n;i++){ fr[i]=2; bk[i]=n; } for (int i = 0; i < n-3; ++i) { int a,b,c; cin>>a>>b>>c; mp[{a,b}]=c; mp[{b,a}]=c; if(a>b) swap(a,b); int ba=(b-a)+1; fr[a]=max(fr[a],ba); bk[a]=min(bk[a],ba); int ab=(n+1)-(b-a); fr[b]=max(fr[b],ab); bk[b]=min(bk[b],ab); } // for (int i = 1; i <=n; ++i) // cout<<fr[i]<<' '<<bk[i]<<endl; if(check1()==0) cout<<"neispravna triangulacija"<<endl; else if(check2()==0) cout<<"neispravno bojenje"<<endl; else cout<<"tocno"<<endl; return 0; }
#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...