Submission #1013184

#TimeUsernameProblemLanguageResultExecution timeMemory
1013184vjudge1Checker (COCI19_checker)C++17
110 / 110
802 ms69548 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]; vector<int> adj[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(){ for (int i = 1; i <=n; ++i){ int sz=adj[i].size(); for(int j=1;j<sz;j++) if(is(adj[i][j-1],adj[i][j]) && diff(adj[i][j-1],i,adj[i][j])==0) return 0; } 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[{i+2,i+1}]=col[i]-'0'; adj[i].push_back(i+1); adj[i+1].push_back(i); } mp[{n,1}]=col[n-1]-'0'; mp[{1,n}]=col[n-1]-'0'; adj[n].push_back(1); adj[1].push_back(n); 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; adj[a].push_back(b); adj[b].push_back(a); 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...