#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include<bits/extc++.h>
//__gnu_pbds
vector<map<int,int> > edge;
vector<int> rt;
vector<int> lt;
vector<bool> vis;
int n;
bool par = 1;
void dfs(int cur){
if(vis[cur]) return ;
n--;
//cout<<cur<<":\n";
vis[cur]=1;
int a = rt[cur];
int b = lt[cur];
int c1 = edge[a][b];
int c2 = edge[a][cur];
int c3 = edge[b][cur];
if(c1==c2 || c2==c3 || c3==c1) par = 0;
rt[b] = a;
lt[a] = b;
/*for(int i=0;i<lt.size();i++){
cout<<i<<":"<<lt[i]<<" "<<rt[i]<<"\n";
}*/
if(edge[rt[a]].count(lt[a])) dfs(a);
if(edge[rt[b]].count(lt[b])) dfs(b);
}
int main(){
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int t;cin>>t;
cin>>n;
rt.resize(n);
lt.resize(n);
edge.resize(n);
vis.resize(n);
string s;cin>>s;
for(int i=0;i<n;i++){
edge[i][(i+1)%n] = s[i]-'0';
edge[(i+1)%n][i] = s[i]-'0';
rt[i] = (i+1)%n;
lt[(i+1)%n] = i;
}
for(int i=0;i<n-3;i++){
int a,b,c;cin>>a>>b>>c;
a--;b--;
edge[a][b] = c;
edge[b][a] = c;
}
for(int i=0;i<n;i++){
if(edge[rt[i]].count(lt[i])) dfs(i);
}
if(n>3){
cout<<"neispravna triangulacija\n";
return 0;
}
if(par){
cout<<"tocno\n";
}else{
cout<<"neispravno bojenje\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
253 ms |
49060 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
258 ms |
49012 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |