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;
#include"trilib.h"
#define N 200005
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
deque<int> l,r,h;
bool ask(int i,int j,int k){return is_clockwise(i,j,k);}
deque<int> hull(deque<int> v){
deque<int> h;
for(auto x:v){
while(h.size()>1&&!ask(h[h.size()-2],h[h.size()-1],x))h.pop_back();
h.push_back(x);
}
return h;
}
int main(){
int n,i;
bool flag=true;
n=get_n();
for(i=3;i<=n;i++){
if(ask(1,2,i))l.push_back(i);
else r.push_back(i);
}
sort(l.begin(),l.end(),[&](const int a,int b){return ask(1,a,b);});
sort(r.begin(),r.end(),[&](const int a,int b){return ask(1,a,b);});
l.push_back(1);
r.push_back(2);
l=hull(l);
r=hull(r);
while(flag){
flag=false;
if(l.size()>1&&r.size()&&!ask(l[l.size()-2],l[l.size()-1],r[0])){
l.pop_back();
flag=true;
}
if(r.size()>1&&l.size()&&!ask(r[r.size()-2],r[r.size()-1],l[0])){
r.pop_back();
flag=true;
}
}
give_answer(l.size()+r.size());
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... |