#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;
int main(){
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int t;cin>>t;
int n;cin>>n;
rt.resize(n);
lt.resize(n);
edge.resize(n);
vector<bool> vis;
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;
}
queue<int> tobe;
for(int i=0;i<n;i++){
if(edge[rt[i]].count(lt[i])) tobe.push(i);
}
bool par = 1;
while(tobe.size() && n>=3) {
int cur = tobe.front();
tobe.pop();
if(vis[cur]){
cout<<"neispravna triangulacija\n";
return 0;
}
vis[cur]=1;
n--;
int a = rt[cur];
int b = lt[cur];
int c1 = edge[cur][a];
int c2 = edge[cur][b];
int c3 = edge[a][b];
if(c1 == c2 || c2==c3 || c1==c3) par=0;
rt[a] = b;
lt[b] = a;
if(edge[rt[a]].count(lt[a])) tobe.push(a);
if(edge[rt[b]].count(lt[b])) tobe.push(b);
}
if(n!=2){
cout<<"neispravna triangulacija"<<"\n";
}
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 |
245 ms |
50124 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
263 ms |
50264 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 |
- |