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"
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
bool sorting(int x,int y) {
return is_clockwise(x,1,y);
}
signed main(){
int n=get_n();
vector <int> v1,v2;
for(int i=3;i<=n;i++){
if(is_clockwise(1,2,i))v1.pb(i);
else v2.pb(i);
}
sort(all(v1),sorting);
sort(all(v2),sorting);
reverse(all(v1));
vector <int> hull2={1,2},hull1={1,2};
for(auto x : v2){
while(hull2.size()>1 && is_clockwise(hull2[hull2.size()-2],hull2[hull2.size()-1],x)){
hull2.pop_back();
}
hull2.pb(x);
}
for(auto x : v1){
while(hull1.size()>1 && !is_clockwise(hull1[hull1.size()-2],hull1[hull1.size()-1],x)){
hull1.pop_back();
}
hull1.pb(x);
}
hull2.pb(hull2.front());
hull2.erase(hull2.begin());
for(int i=hull1.size()-1;i>=2;i--){
int x=hull1[i];
while(hull2.size()>1 && is_clockwise(hull2[hull2.size()-2],hull2[hull2.size()-1],x)){
hull2.pop_back();
}
hull2.pb(x);
}
reverse(all(hull2));
while(hull2.size()>2 && !is_clockwise(hull2[hull2.size()-2],hull2[hull2.size()-1],hull2[0])){
hull2.pop_back();
}
reverse(all(hull2));
while(hull2.size()>2 && is_clockwise(hull2[hull2.size()-2],hull2[hull2.size()-1],hull2[0])){
hull2.pop_back();
}
give_answer(hull2.size());
}
# | 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... |