# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
222382 | tqbfjotld | Checker (COCI19_checker) | C++14 | 147 ms | 16472 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int n;
vector<pair<pair<int,int>,int> > sides;
int iterate(int pos){
int a = sides[pos].first.first;
int b = -sides[pos].first.second;
if (pos==sides.size()-1){
return pos;
}
if (sides[pos+1].first.first==b){
return pos;
}
if (sides[pos+1].first.first!=a){
return -1;
}
int res = iterate(pos+1);
if (res==-1) return -1;
if (-sides[res+1].first.second!=b){
return -1;
}
int res2 = iterate(res+1);
if (res2==-1){
return -1;
}
return res2;
}
int iterate2(int pos){
int a = sides[pos].first.first;
int b = -sides[pos].first.second;
if (pos==sides.size()-1){
return pos;
}
if (sides[pos+1].first.first==b){
return pos;
}
int res = iterate2(pos+1);
if (res==-1) return -1;
int res2 = iterate2(res+1);
if (res2==-1){
return -1;
}
//printf("triangle of (%d,%d),(%d,%d),(%d,%d)\n",a,b,sides[pos+1].first.first,sides[pos+1].first.second,sides[res+1].first.first,sides[res+1].first.second);
if (sides[pos].second==sides[pos+1].second) return -1;
if (sides[pos].second==sides[res+1].second) return -1;
if (sides[pos+1].second==sides[res+1].second) return -1;
//printf("sides %d %d %d\n",sides[pos].second,sides[pos+1].second,sides[res+1].second);
return res2;
}
int main(){
int subtask;
scanf("%d",&subtask);
scanf("%d",&n);
for (int x = 0; x<n; x++){
char c;
scanf(" %c",&c);
if (x!=n-1){
sides.push_back({{x+1,-x-2},c-'0'});
}
else{
sides.push_back({{1,-n},c-'0'});
}
}
for (int x = 0; x<n-3; x++){
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
if (b<a) swap(a,b);
if (a+1==b){
printf("neispravna triangulacija");
return 0;
}
sides.push_back({{a,-b},c});
}
sort(sides.begin(),sides.end());
for (int x = 1; x<sides.size(); x++){
if (sides[x].first==sides[x-1].first){
printf("neispravna triangulacija");
return 0;
}
}
if (iterate(0)==-1){
printf("neispravna triangulacija");
return 0;
}
if (iterate2(0)==-1){
printf("neispravno bojenje");
}
else{
printf("tocno");
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |