# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1013148 |
2024-07-03T08:27:25 Z |
vjudge1 |
Checker (COCI19_checker) |
C++17 |
|
3000 ms |
54612 KB |
#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];
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(){
vector<int> v1,v2;
for (int i = 1; i <=n; ++i)
v1.push_back(i);
while(v1.size()>2){
int sz=v1.size();
if(is(v1[sz-1],v1[1])){
if(diff(v1[sz-1],v1[0],v1[1])==0)
return 0;
}
else
v2.push_back(v1[0]);
for(int i=1;i<sz-1;i++){
if(is(v1[i-1],v1[i+1])){
if(diff(v1[i-1],v1[i],v1[i+1])==0)
return 0;
}
else
v2.push_back(v1[i]);
}
if(v1.size()==v2.size())
return 0;
if(is(v1[sz-2],v1[0])){
if(diff(v1[sz-2],v1[sz-1],v1[0])==0)
return 0;
}
else
v2.push_back(v1[sz-1]);
// for(int i:v1)
// cout<<i<<' ';
// cout<<endl;
v1=v2;
v2.clear();
}
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';
}
mp[{n,1}]=col[n-1]-'0';
mp[{1,n}]=col[n-1]-'0';
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;
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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1605 ms |
54360 KB |
Output is correct |
2 |
Correct |
1710 ms |
54608 KB |
Output is correct |
3 |
Correct |
461 ms |
52192 KB |
Output is correct |
4 |
Correct |
414 ms |
52228 KB |
Output is correct |
5 |
Correct |
434 ms |
52192 KB |
Output is correct |
6 |
Execution timed out |
3077 ms |
54488 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1763 ms |
54448 KB |
Output is correct |
2 |
Correct |
1706 ms |
54460 KB |
Output is correct |
3 |
Correct |
691 ms |
54612 KB |
Output is correct |
4 |
Correct |
578 ms |
54468 KB |
Output is correct |
5 |
Correct |
413 ms |
53336 KB |
Output is correct |
6 |
Execution timed out |
3058 ms |
54360 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |