이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "trilib.h"
#include <cstdio>
#include <algorithm>
#include <deque>
std::deque<int> hull;
void append(int p){
while(hull.size()>=2&&is_clockwise(hull[hull.size()-2],hull[hull.size()-1],p)){
hull.pop_back();
}
while(hull.size()>=2&&is_clockwise(hull[0],hull[1],p)){
hull.pop_front();
}
hull.push_back(p);
}
template<class Iterator>
void insert(Iterator it,int p){
std::rotate(hull.begin(),it,hull.end());
append(p);
}
void add(int p){
if(is_clockwise(hull[hull.size()-1],hull[0],p)){
insert(hull.end(),p);
}else{
int low=0,high=hull.size()-1;
//clock(-1,low,p)=false
//clock(-1,high,p)=true
while(high-low>1){
int mid=(low+high)/2;
if(is_clockwise(hull[hull.size()-1],hull[mid],p)){
high=mid;
}else{
low=mid;
}
}
if(is_clockwise(hull[low],hull[high],p)){
insert(hull.begin()+high,p);
}
}
}
int main(){
int N=get_n();
hull.push_back(1);
hull.push_back(2);
for(int i=3;i<=N;i++){
add(i);
}
printf("%d\n",(int)hull.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... |