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>
#include "trilib.h"
using namespace std;
const int mxn=500+5;
int n,mark[mxn],ans=3,nxt[mxn],pre[mxn],st=1;
void merge(int x,int y){
pre[y]=x;
nxt[x]=y;
}
int main(){
n=get_n();
if(is_clockwise(1,2,3)){
merge(1,2);
merge(2,3);
merge(3,1);
}
else{
merge(2,1);
merge(3 ,2);
merge(1,3);
}
for(int i=4;i<=n;i++){
while(!mark[st]){
mark[st]=1;
if(is_clockwise(st,nxt[st],i)){
st=nxt[st];
continue;
}
ans++;
merge(i,nxt[st]);
merge(st,i);
while(!is_clockwise(i,nxt[i],nxt[nxt[i]])){
ans--;
merge(i,nxt[nxt[i]]);
}
while(!is_clockwise(pre[st],st,i)){
ans--;
merge(pre[st],i);
st=pre[st];
}
break;
}
memset(mark,0,sizeof mark);
}
give_answer(ans);
return 0;
}
# | 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... |