이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "trilib.h"
using namespace std;
int main()
{
int n=get_n();
vector<int> l,r;
for(int i=3;i<=n;i++)
{
if(is_clockwise(1,2,i)) r.push_back(i);
else l.push_back(i);
}
sort(l.begin(),l.end(),[](int a,int b){return is_clockwise(1,a,b);});
sort(r.begin(),r.end(),[](int a,int b){return is_clockwise(1,a,b);});
reverse(l.begin(),l.end());
vector<int> one={1,2};
for(int a:l)
{
while(one.size()>=2&&is_clockwise(one[one.size()-2],one.back(),a)) one.pop_back();
one.push_back(a);
}
vector<int> two={1,2};
for(int a:r)
{
while(two.size()>=2&&is_clockwise(two[two.size()-2],two.back(),a)==0) two.pop_back();
two.push_back(a);
}
if(min(one.size(),two.size())==2) give_answer(max(one.size(),two.size()));
else
{
one.erase(one.begin());
two.erase(two.begin());
one.push_back(1);
bool t=1;
while(1)
{
bool b=0;
if(one.size()>=2&&is_clockwise(one[one.size()-2],one.back(),two.back())==t)
{
one.pop_back();
b=1;
}
if(two.size()>=2&&is_clockwise(one.back(),two.back(),two[two.size()-2])==t)
{
two.pop_back();
b=1;
}
if(!b)
{
if(t==1)
{
t=0;
reverse(one.begin(),one.end());
reverse(two.begin(),two.end());
two.pop_back();
}
else break;
}
}
give_answer(one.size()+two.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... |