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 <bits/stdc++.h>
using namespace std;
bool cmp(int A, int B) { return is_clockwise(1, A, B); }
vector<int> d[2]{{2}, {2}}, h[2];
int main() {
int n = get_n();
for (int i = 3; i <= n; i++) d[is_clockwise(1, 2, i)].push_back(i);
for (int i = 0; i < 2; i++) {
sort(d[i].begin(), d[i].end(), cmp);
for (int j : d[i]) {
while (h[i].size() > 1 && is_clockwise(j, h[i].back(), h[i][h[i].size() - 2]))
h[i].pop_back();
h[i].push_back(j);
}
if (i) reverse(h[i].begin(), h[i].end());
h[i].insert(h[i].begin(), 1);
}
if (min(h[0].size(), h[1].size()) == 2)
return give_answer(max(h[0].size(), h[1].size())), 0;
for (int i = 0; i < 2; i++) {
h[0].pop_back();
while (true) {
if (h[0].size() > 1 && is_clockwise(h[1].back(), h[0].back(), h[0][h[0].size() - 2]))
h[0].pop_back();
else if (h[1].size() > 1 && is_clockwise(h[1][h[1].size() - 2], h[1].back(), h[0].back()))
h[1].pop_back();
else break;
}
swap(h[0], h[1]);
reverse(h[0].begin(), h[0].end());
reverse(h[1].begin(), h[1].end());
}
give_answer(h[0].size() + h[1].size());
return 0;
}
# | 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... |