This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|
**/
#include <bits/stdc++.h>
#include "trilib.h"
using namespace std;
typedef long long ll;
const int N_MAX = 40000;
int n;
bool side[N_MAX + 2];
int p[N_MAX + 2];
bool cmp (const int &i, const int &j) {
if (side[i] != side[j]) {
return side[i] < side[j];
} else {
return !is_clockwise(i, 1, j);
}
}
int main () {
n = get_n();
iota(p + 1, p + n + 1, 1);
for (int i = 3; i <= n; i++) {
side[i] = !is_clockwise(1, 2, i);
}
sort(p + 3, p + n + 1, cmp);
for (int i = 3; i <= n; i++) {
side[i] = !is_clockwise(1, 2, p[i]);
}
for (int i = 2; i < n; i++) {
if (side[i] == 0 && side[i + 1] == 1) {
rotate(p + 2, p + i + 1, p + n + 1);
break;
}
}
deque <int> st;
for (int k = 1; k <= n; k++) {
int i = p[k];
while ((int) st.size() >= 2 && !is_clockwise(st.end()[-2], st.end()[-1], i)) {
st.pop_back();
}
st.push_back(i);
}
while ((int) st.size() >= 3) {
if (!is_clockwise(st.end()[-2], st.end()[-1], st[0])) {
st.pop_back();
} else if (!is_clockwise(st.end()[-1], st[0], st[1])) {
st.pop_front();
} else {
break;
}
}
give_answer((int) st.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... |