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"
using namespace std;
int n,centru;
bool cmp(int x, int y)
{
if(is_clockwise(centru,x,y))
return 1;
return 0;
}
bool is_inter(int x, int a, int b, int c)///is x in the triangle (a,b,c)
{
if(!is_clockwise(a,b,c))
{
if(is_clockwise(x,b,a) && is_clockwise(x,c,b) && is_clockwise(x,a,c))
return 1;
else
return 0;
}
else if(is_clockwise(x,b,c) && is_clockwise(x,a,b) && is_clockwise(x,c,a))
return 1;
return 0;
}
signed main()
{
n = get_n();
if(n==3)
{
give_answer(3);
return 0;
}
if(n<=50)
{
int cnt=0;
for(int i=1;i<=n;i++)
{
bool bun=1;
int a=1;
if(i==1)
a=2;
for(int b=a+1;b<=n;b++)
{
if(!bun) break;
if(b==i)
continue;
for(int c=b+1;c<=n;c++)
{
if(!bun) break;
if(c==i)
continue;
if(is_inter(i,a,b,c))
bun=0;
}
}
if(bun)
cnt++;
}
give_answer(cnt);
return 0;
}
centru=n/2;
vector<int> ord;
for(int i=1;i<=n;i++)
if(i!=centru)
ord.push_back(i);
sort(ord.begin(),ord.end(),cmp);
vector<int> hull;
hull.push_back(ord[0]);
hull.push_back(ord[1]);
for(int i=2;i<ord.size();i++)
{
while((int)hull.size()>=2 && is_inter(hull.back(), centru, hull[(int)hull.size()-2], ord[i]))
hull.pop_back();
if(((int)hull.size()<2 || (!is_inter(ord[i], centru, hull.back(), hull[0]))) && ((int)hull.size()<3 || 1 || (!is_inter(ord[i],hull[(int)hull.size()-2],hull.back(),hull[0]) /*&& is_clockwise(hull[(int)hull.size()-2],hull.back(),hull[0])*/)))
hull.push_back(ord[i]);
}
//if((int)hull.size()>=3 && !is_clockwise(hull.back(),hull[0],hull[1]))
// hull.erase(hull.begin());
int idk=1;
if((int)hull.size()>=3)
{
for(int i=0;i<hull.size();i++)
{
if(!is_clockwise(hull[i],hull[(i+1)%((int)hull.size())],hull[(i+2)%((int)hull.size())]))
{
while(1)
n=0;
}
if(is_inter(centru,hull[i],hull[(i+1)%((int)hull.size())],hull[(i+2)%((int)hull.size())]))
{
idk=0;
}
}
}
give_answer(max(3,(int)hull.size() + idk));
}
Compilation message (stderr)
tri.cpp: In function 'int main()':
tri.cpp:70:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
70 | for(int i=2;i<ord.size();i++)
| ~^~~~~~~~~~~
tri.cpp:82:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
82 | for(int i=0;i<hull.size();i++)
| ~^~~~~~~~~~~~
# | 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... |