Submission #464592

#TimeUsernameProblemLanguageResultExecution timeMemory
464592JasiekstrzChecker (COCI19_checker)C++17
110 / 110
114 ms14924 KiB
#include<bits/stdc++.h> #define fi first #define se second using namespace std; const int N=2e5; const string OK="tocno\n",WRONGCOL="neispravno bojenje\n",WRONGTRI="neispravna triangulacija\n"; int tab[N+10]; vector<pair<int,int>> e[N+10]; vector<int> st; bool patriotic(int a,int b,int c) { return (a!=b && a!=c && b!=c); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int sub,n; cin>>sub>>n; for(int i=1;i<=n;i++) { char c; cin>>c; tab[i]=c-'1'; } for(int i=1;i<=n-3;i++) { int a,b,c; cin>>a>>b>>c; c--; if(a>b) swap(a,b); e[b].emplace_back(a,c); } for(int i=1;i<=n;i++) { sort(e[i].begin(),e[i].end()); reverse(e[i].begin(),e[i].end()); } for(int i=1;i<=n;i++) { for(auto [a,c]:e[i]) { if(st.size()<2 || st[st.size()-2]!=a) { cout<<WRONGTRI; return 0; } if(!patriotic(c,tab[st[st.size()-2]],tab[st.back()])) { cout<<WRONGCOL; return 0; } st.pop_back(); tab[st.back()]=c; } st.push_back(i); } if(st.size()!=3) cout<<WRONGTRI; else if(!patriotic(tab[st[0]],tab[st[1]],tab[st[2]])) cout<<WRONGCOL; else cout<<OK; 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...