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"
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<long long, long long>
#define pb push_back
#define rep(i, b) for(int i = 0; i < (b); ++i)
#define rep2(i,a,b) for(int i = a; i <= (b); ++i)
#define rep3(i,a,b,c) for(int i = a; i <= (b); i+=c)
#define count_bits(x) __builtin_popcountll((x))
#define all(x) (x).begin(),(x).end()
#define size(x) (int)(x).size()
#define forall(it,x) for(auto& it:(x))
using namespace std;
//mt19937 mt;void random(){mt.seed(chrono::time_point_cast<chrono::milliseconds>(chrono::high_resolution_clock::now()).time_since_epoch().count());}
//ll rand(ll a, ll b) {return a + (mt() % (b-a+1));}
const int INF = 1e9+50;
const ll INF_L = 1e18+40;
const ll MOD = 1e9+7;
bool odw[501];
void solve()
{
int n = get_n();
set<int> s;
rep2(i,1,n) s.insert(i);
vector<pii> edges;
while(size(s) > 1)
{
int s1 = *s.begin();
auto it = s.end();
it--;
int s2 = *it;
set<int> zero;
set<int> one;
rep2(i,1,n)
{
if(i == s1 || i == s2) continue;
if(is_clockwise(s1,s2,i))
{
one.insert(i);
}
else
{
zero.insert(i);
}
}
if(size(zero) < size(one)) swap(zero,one);
if(size(one) == 0)
{
edges.pb({s1,s2});
break;
}
else
{
s = one;
}
}
if(size(edges) == 0)
{
int p = *s.begin();
rep2(i,1,n)
{
if(i == p) continue;
bool b0 = false;
bool b1 = false;
rep2(k,1,n)
{
if(k == i || k == p) continue;
if(is_clockwise(p,i,k)) b1 = true;
else b0 = true;
}
if(b0 && b1)
{
}
else
{
edges.pb({p,i});
break;
}
}
}
//cout << edges[0].ff << " " << edges[0].ss << "\n";
odw[edges[0].ff] = true;
odw[edges[0].ss] = true;
while(true)
{
pii pop = edges[size(edges)-1];
int p = pop.ss;
int cur = 1;
if(p == 1 || pop.ff == 1)
{
if(p == 2 || pop.ff == 2) cur = 3;
else cur = 2;
}
rep2(i,1,n)
{
// cout << pop.ff << " " << p << " " << cur << " " << i << "\n";
if(i == p || i == cur || i == pop.ff) continue;
bool w1 = is_clockwise(pop.ff,p,cur);
bool w2 = is_clockwise(cur,p,i);
if(w1 == w2)
{
cur = i;
}
}
edges.pb({p,cur});
if(odw[cur]) break;
odw[cur] = true;
}
give_answer(size(edges));
}
int main()
{
//ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//random();
int t = 1;
//cin >> t;
while(t--) solve();
}
# | 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... |