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, origin;
vector<int> arr;
bool compare(int i, int j) {
return is_clockwise(i, origin, j);
}
void solve() {
n = get_n();
int k = 1, l = 2, t = 0;
while (++t) {
bool f = false;
for (int i = 1; i <= n; i++) {
if (i != k && i != l) {
if (is_clockwise(k, l, i)) {
f = true;
if (t % 2 == 1) k = i;
else l = i;
break;
}
}
}
if (!f) break;
}
origin = k;
for (int i = 1; i <= n; i++) if (i != origin) arr.push_back(i);
sort(arr.begin(), arr.end(), compare);
stack<int> stk;
stk.push(origin);
stk.push(arr[0]);
for (int i = 1; i <= n; i++) {
int a = stk.top(); stk.pop();
while (stk.size() >= 2 && !is_clockwise(stk.top(), a, i)) {
stk.top() = a; stk.pop();
}
stk.push(a);
stk.push(i);
}
give_answer(stk.size());
}
int main() {
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... |