This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <stack>
#include <cassert>
#include <iterator>
#include <bitset>
#include <fstream>
#ifndef death
#include<trilib.h>
#endif // death
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(),v.end()
using namespace std;
#ifdef death
int get_n()
{
cout << "N::" << endl;
int x;
cin >> x;
return x;
}
bool is_clockwise(int a, int b, int c)
{
cout << ":::" << a << " " << b << " " << c << endl;
int x;
cin >> x;
return x;
}
void give_answer(int x)
{
cout << x << endl;
}
#endif // death
map<pair<int, pair<int, int>>, bool> used, pre;
bool cw(int a, int b, int c)
{
if (used[MP(a, MP(b, c))])
return pre[MP(a, MP(b, c))];
used[MP(a, MP(b, c))] = 1;
return pre[MP(a, MP(b, c))] = is_clockwise(a, b, c);
}
bool ccw(int a, int b, int c)
{
return !cw(a, b, c);
}
int convex(vector<int> p)
{
vector<int> up, down;
int st, en;
st = p[0];
en = p.back();
reverse(all(p));
p.pop_back();
reverse(all(p));
p.pop_back();
vector<int> add = p;
p.clear();
p.PB(st);
for (int i = 0; i < add.size(); i++)
for (int j = 0; j < add.size(); j++)
p.PB(add[j]);
p.PB(en);
up.PB(p[0]);
down.PB(p[0]);
for (int i = 1; i < p.size(); i++)
{
if (i == p.size() - 1 || cw(p[0], p[i], p[p.size() - 1]))
{
while (up.size() > 1 && (!cw(up[up.size() - 2], up[up.size() - 1], p[i]) || up.back() == p[i]))
up.pop_back();
up.PB(p[i]);
}
if (i == p.size() - 1 || ccw(p[0], p[i], p[p.size() - 1]))
{
while (down.size() > 1 && (!cw(down[down.size() - 2], down[down.size() - 1], p[i]) || down.back() == p[i]))
down.pop_back();
down.PB(p[i]);
}
}
set<int> s;
for (int i = 0; i < up.size(); i++)
s.insert(up[i]);
for (int i = 0; i < down.size(); i++)
s.insert(down[i]);
return s.size();
}
int ans, n;
vector<int> p;
int main()
{
n = get_n();
for (int i = 1; i <= n; i++)
p.PB(i);
ans = max(ans, convex(p));
for (int i = 1; i < n; i++)
{
swap(p[1], p[i]);
ans = max(ans, convex(p));
swap(p[1], p[i]);
}
give_answer(ans);
return 0;
}
/*
*/
Compilation message (stderr)
tri.cpp: In function 'int convex(std::vector<int>)':
tri.cpp:88:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < add.size(); i++)
~~^~~~~~~~~~~~
tri.cpp:89:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = 0; j < add.size(); j++)
~~^~~~~~~~~~~~
tri.cpp:95:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 1; i < p.size(); i++)
~~^~~~~~~~~~
tri.cpp:97:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (i == p.size() - 1 || cw(p[0], p[i], p[p.size() - 1]))
~~^~~~~~~~~~~~~~~
tri.cpp:104:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (i == p.size() - 1 || ccw(p[0], p[i], p[p.size() - 1]))
~~^~~~~~~~~~~~~~~
tri.cpp:112:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < up.size(); i++)
~~^~~~~~~~~~~
tri.cpp:114:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < down.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... |