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 "trilib.h"
#include <vector>
#include <algorithm>
#include <iostream>
#define int int64_t
using namespace std;
signed main()
{
int n = get_n();
vector<int> next(n, -1);
if (is_clockwise(1, 2, 3))
{
next[0] = 1;
next[1] = 2;
next[2] = 0;
}
else
{
next[0] = 2;
next[1] = 0;
next[2] = 1;
}
int start = 0;
for (int i = 3; i < n; i++)
{
int curr = -1;
bool firstconc = false;
bool sec = false;
while (curr != start && sec)
{
if (curr == start) sec = true;
if (curr == -1)
{
curr = start;
}
bool cl = is_clockwise(curr + 1, i + 1, next[curr] + 1);
if (cl)
{
if (!firstconc) continue;
next[i] = next[curr];
next[curr] = i;
while (true)
{
if (is_clockwise(i + 1, next[i] + 1, next[next[i]] + 1)) break;
else
{
int old = next[i];
next[i] = next[next[i]];
next[old] = -1;
if (old == start) start = i;
}
}
break;
}
else
{
firstconc = true;
curr = next[curr];
}
}
}
/*int curr = -1;
while (curr != start)
{
if (curr == -1) curr = start;
cout << curr << " ";
curr = next[curr];
}*/
int res = 0;
for (int i : next)
{
if (i != -1) res++;
}
give_answer(res);
}
# | 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... |