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 = l;
for (int i = 1; i <= n; i++) if (i != origin) arr.push_back(i);
sort(arr.begin(), arr.end(), compare);
assert(arr[0] == k);
stack<int> stk;
stk.push(origin);
stk.push(arr[0]);
for (int i = 1; i < arr.size(); i++) {
int a = stk.top(); stk.pop();
while (stk.size() >= 1 && is_clockwise(stk.top(), a, arr[i])) {
a = stk.top(); stk.pop();
}
stk.push(a);
stk.push(arr[i]);
}
give_answer(stk.size());
}
int main() {
solve();
}
Compilation message (stderr)
tri.cpp: In function 'void solve()':
tri.cpp:43:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | for (int i = 1; i < arr.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... |