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 <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "trilib.h"
using namespace std;
using namespace __gnu_pbds;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int nn; int god;
map<vector<int>,bool> ma;
bool is_cl(int x, int y, int z)
{
if(ma.find({x,y,z})!=ma.end()) return ma[{x,y,z}];
if(ma.find({x,z,y})!=ma.end()) return !ma[{x,z,y}];
if(ma.find({y,x,z})!=ma.end()) return !ma[{y,x,z}];
if(ma.find({y,z,x})!=ma.end()) return ma[{y,z,x}];
if(ma.find({z,x,y})!=ma.end()) return ma[{z,x,y}];
if(ma.find({z,y,x})!=ma.end()) return !ma[{z,y,x}];
return (ma[{x,y,z}] = is_clockwise(x+1,y+1,z+1));
}
bool cmp(int x, int y)
{
return is_cl(god,x,y);
}
int ans;
void solve_init(int u)
{
vector<int> vec;
for(int i=0;i<nn;i++)
{
if(u!=i) vec.pb(i);
}
god=u;
stable_sort(vec.begin(),vec.end(),cmp);
vector<int> S;
S.pb(u);
S.pb(vec[0]); S.pb(vec[1]);
for(int i=2;i<vec.size();i++)
{
int u=vec[i];
while(S.size()>=2&&!is_cl(S[int(S.size())-2], S[int(S.size())-1], u))
{
S.pop_back();
}
S.pb(u);
}
ans=min(ans,int(S.size()));
}
int main()
{
nn = get_n();
ans = nn;
vector<int> vertices;
for(int i=0;i<nn;i++) vertices.pb(i);
random_shuffle(vertices.begin(),vertices.end());
for(int i=0;i<nn;i++)
{
if(nn>500&&i>=2) break;
solve_init(vertices[i]);
}
give_answer(ans);
}
Compilation message (stderr)
tri.cpp: In function 'void solve_init(int)':
tri.cpp:51:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=2;i<vec.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... |