This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define wiwihorz
#pragma GCC optimize("Ofast")
#pragma loop-opt(on)
#include <bits/stdc++.h>
#include "trilib.h"
#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define rrep(i, a, b) for(int i = b; i >= a; i--)
#define all(x) x.begin(), x.end()
using namespace std;
#ifdef wiwihorz
#define print(a...) cerr << "Line " << __LINE__ <<": ", kout("[" + string(#a) + "] = ", a)
void kout() {cerr << endl;}
void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...); }
#else
#define print(...) 0
#define vprint(...) 0
#endif
namespace solver {
vector<int> a, b, vis;
void solve() {
int n = get_n();
vis.assign(n + 1, 0);
rep(i, 1, n) a.push_back(i);
sort(all(a), [](int x, int y) {
if(x == 1 || y == 1) return (x == 1 ? 1 : 0);
else return is_clockwise(x, 1, y);
});
for(auto i : a) {
while(b.size() > 1 && !is_clockwise(
b[b.size() - 1], b[b.size() - 2], i)) b.pop_back();
b.push_back(i);
}
int cnt = 0, ft = 0, bk = b.size() - 1;
while(++cnt && bk - ft + 1 > 3) {
if(cnt & 1) {
if(vis[b[ft + 1]]) break;
vis[b[ft + 1]] = 1;
while(bk - ft + 1 > 3 &&
is_clockwise(b[ft], b[ft + 1], b[bk])) ft++;
}
else {
if(vis[b[bk - 1]]) break;
vis[b[bk - 1]] = 1;
while(bk - ft + 1 > 3 &&
!is_clockwise(b[bk], b[bk - 1], b[ft])) bk --;
}
}
give_answer(bk - ft + 1);
}
};
using namespace solver;
signed main() {
ios::sync_with_stdio(false), cin.tie(0);
solve();
return 0;
}
Compilation message (stderr)
tri.cpp:3: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
3 | #pragma loop-opt(on)
|
tri.cpp:14:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
14 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
| ^~~~
tri.cpp:14:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
14 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
| ^~~~
# | 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... |