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;
const int N = 40040;
int n, inv[N];
int main() {
n = get_n();
int u = 1, v = 2;
vector<int> a, b;
for (int i = 3; i <= n; i++) {
if (!is_clockwise(u, v, i))
a.push_back(i);
else
b.push_back(i);
}
if (a.size() > b.size())
swap(u, v);
sort(a.begin(), a.end(), [&](int i, int j) {
return !is_clockwise(u, i, j);
});
vector<int> c = a;
sort(c.begin(), c.end(), [&](int i, int j) {
return is_clockwise(v, i, j);
});
for (int i = 0; i < c.size(); i++)
inv[c[i]] = i;
deque<int> hull;
int mx = -1;
for (int i = 0; i < a.size(); i++) {
if (inv[a[i]] > mx)
mx = inv[a[i]], hull.push_back(a[i]);
}
sort(b.begin(), b.end(), [&](int i, int j) {
return is_clockwise(v, i, j);
});
for (int x : b) {
while (hull.size() >= 2) {
if (!is_clockwise(hull[hull.size() - 2], hull.back(), x))
hull.pop_back();
else
break;
}
hull.push_back(x);
}
while (hull.size() >= 3) {
if (!is_clockwise(hull.back(), hull[0], hull[1]))
hull.pop_front();
else
break;
}
give_answer((int)hull.size());
}
Compilation message (stderr)
tri.cpp: In function 'int main()':
tri.cpp:33:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for (int i = 0; i < c.size(); i++)
| ~~^~~~~~~~~~
tri.cpp:38:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
38 | for (int i = 0; i < a.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... |