#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4956 KB |
Output is correct |
2 |
Correct |
1 ms |
4956 KB |
Output is correct |
3 |
Correct |
1 ms |
4956 KB |
Output is correct |
4 |
Correct |
1 ms |
4956 KB |
Output is correct |
5 |
Correct |
1 ms |
4956 KB |
Output is correct |
6 |
Correct |
1 ms |
4956 KB |
Output is correct |
7 |
Correct |
1 ms |
4956 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4956 KB |
Output is correct |
2 |
Correct |
1 ms |
4956 KB |
Output is correct |
3 |
Correct |
1 ms |
4956 KB |
Output is correct |
4 |
Correct |
1 ms |
4956 KB |
Output is correct |
5 |
Correct |
1 ms |
4956 KB |
Output is correct |
6 |
Correct |
1 ms |
4956 KB |
Output is correct |
7 |
Correct |
1 ms |
4956 KB |
Output is correct |
8 |
Correct |
4 ms |
5724 KB |
Output is correct |
9 |
Correct |
4 ms |
5780 KB |
Output is correct |
10 |
Correct |
3 ms |
5724 KB |
Output is correct |
11 |
Correct |
3 ms |
5724 KB |
Output is correct |
12 |
Correct |
3 ms |
5724 KB |
Output is correct |
13 |
Correct |
3 ms |
5724 KB |
Output is correct |
14 |
Correct |
3 ms |
5724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
696 ms |
69464 KB |
Output is correct |
2 |
Correct |
721 ms |
69344 KB |
Output is correct |
3 |
Correct |
476 ms |
69464 KB |
Output is correct |
4 |
Correct |
467 ms |
69272 KB |
Output is correct |
5 |
Correct |
548 ms |
69480 KB |
Output is correct |
6 |
Correct |
749 ms |
67040 KB |
Output is correct |
7 |
Correct |
735 ms |
67144 KB |
Output is correct |
8 |
Correct |
577 ms |
66984 KB |
Output is correct |
9 |
Correct |
616 ms |
66948 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
751 ms |
69548 KB |
Output is correct |
2 |
Correct |
772 ms |
69252 KB |
Output is correct |
3 |
Correct |
724 ms |
69344 KB |
Output is correct |
4 |
Correct |
595 ms |
69376 KB |
Output is correct |
5 |
Correct |
539 ms |
69388 KB |
Output is correct |
6 |
Correct |
790 ms |
67140 KB |
Output is correct |
7 |
Correct |
802 ms |
67096 KB |
Output is correct |
8 |
Correct |
636 ms |
67108 KB |
Output is correct |
9 |
Correct |
589 ms |
66944 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4956 KB |
Output is correct |
2 |
Correct |
1 ms |
4956 KB |
Output is correct |
3 |
Correct |
1 ms |
4956 KB |
Output is correct |
4 |
Correct |
1 ms |
4956 KB |
Output is correct |
5 |
Correct |
1 ms |
4956 KB |
Output is correct |
6 |
Correct |
1 ms |
4956 KB |
Output is correct |
7 |
Correct |
1 ms |
4956 KB |
Output is correct |
8 |
Correct |
4 ms |
5724 KB |
Output is correct |
9 |
Correct |
4 ms |
5780 KB |
Output is correct |
10 |
Correct |
3 ms |
5724 KB |
Output is correct |
11 |
Correct |
3 ms |
5724 KB |
Output is correct |
12 |
Correct |
3 ms |
5724 KB |
Output is correct |
13 |
Correct |
3 ms |
5724 KB |
Output is correct |
14 |
Correct |
3 ms |
5724 KB |
Output is correct |
15 |
Correct |
696 ms |
69464 KB |
Output is correct |
16 |
Correct |
721 ms |
69344 KB |
Output is correct |
17 |
Correct |
476 ms |
69464 KB |
Output is correct |
18 |
Correct |
467 ms |
69272 KB |
Output is correct |
19 |
Correct |
548 ms |
69480 KB |
Output is correct |
20 |
Correct |
749 ms |
67040 KB |
Output is correct |
21 |
Correct |
735 ms |
67144 KB |
Output is correct |
22 |
Correct |
577 ms |
66984 KB |
Output is correct |
23 |
Correct |
616 ms |
66948 KB |
Output is correct |
24 |
Correct |
751 ms |
69548 KB |
Output is correct |
25 |
Correct |
772 ms |
69252 KB |
Output is correct |
26 |
Correct |
724 ms |
69344 KB |
Output is correct |
27 |
Correct |
595 ms |
69376 KB |
Output is correct |
28 |
Correct |
539 ms |
69388 KB |
Output is correct |
29 |
Correct |
790 ms |
67140 KB |
Output is correct |
30 |
Correct |
802 ms |
67096 KB |
Output is correct |
31 |
Correct |
636 ms |
67108 KB |
Output is correct |
32 |
Correct |
589 ms |
66944 KB |
Output is correct |
33 |
Correct |
768 ms |
69320 KB |
Output is correct |
34 |
Correct |
737 ms |
69248 KB |
Output is correct |
35 |
Correct |
535 ms |
69344 KB |
Output is correct |
36 |
Correct |
555 ms |
69288 KB |
Output is correct |
37 |
Correct |
576 ms |
69460 KB |
Output is correct |
38 |
Correct |
548 ms |
69232 KB |
Output is correct |
39 |
Correct |
592 ms |
69348 KB |
Output is correct |
40 |
Correct |
789 ms |
67284 KB |
Output is correct |
41 |
Correct |
767 ms |
67048 KB |
Output is correct |
42 |
Correct |
556 ms |
67028 KB |
Output is correct |
43 |
Correct |
663 ms |
67044 KB |
Output is correct |