이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |