Submission #240203

#TimeUsernameProblemLanguageResultExecution timeMemory
240203DavidDamianChecker (COCI19_checker)C++11
0 / 110
15 ms768 KiB
#include <bits/stdc++.h> using namespace std; ///Subtask 1 ///O(n^3) #define debug(x) cout<<#x<<" = "<<x<<endl struct edge { int from,to; edge(){} edge(int from,int to) : from(from),to(to){} }; int n; int color[305][305]; int segments[305]; bool checkTriang() { vector<edge> edges; for(int i=1;i<=n-3;i++){ int a,b,c; cin>>a>>b>>c; if(color[a][b]!=0) return false; color[a][b]=color[b][a]=c; for(edge e: edges){ for(int u=e.from+1;u!=e.to;u=(u<n)? u+1 : 1){ segments[u]=1; } for(int u=e.to+1;u!=e.from;u=(u<n)? u+1 : 1){ segments[u]=2; } if(segments[a]!=0 && segments[b]!=0 && segments[a]!=segments[b]) return false; for(int u=e.from+1;u!=e.to;u=(u<n)? u+1 : 1){ segments[u]=0; } for(int u=e.to+1;u!=e.from;u=(u<n)? u+1 : 1){ segments[u]=0; } } edges.push_back(edge(a,b)); } return true; } bool checkColor() { for(int i=1;i<=n;i++){ for(int j=i+1;j<=n;j++){ if(color[i][j]==0) continue; for(int k=j+1;k<=n;k++){ if(color[i][k]==0 || color[j][k]==0) continue; if(color[i][j]==color[i][k] || color[i][k]==color[j][k] || color[i][j]==color[j][k]) return false; } } } return true; } int main() { cin>>n; if(n>300) return 0; for(int i=1;i<=n;i++){ int j=(i<n)? i+1 : 1; char c; cin>>c; color[i][j]=color[j][i]=c-'0'; } if(checkTriang()==false){ cout<<"neispravna triangulacija"; return 0; } if(checkColor()==false){ cout<<"neispravno bojenje"; return 0; } cout<<"tocno"; 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...