This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
#include "trilib.h"
using namespace std;
#define nl '\n'
#define pb push_back
#define sz(x) int(x.size())
template<class T> using V = vector<T>;
using vi = V<int>;
mt19937 rng(0);
// g++-13 -O2 trilib.cpp A.cpp -std=c++17 -o ./G
int main() {
cin.tie(0)->sync_with_stdio(0);
int N = get_n();
function<vi(vi)> dnc = [&](vi A) {
if (sz(A) <= 1) return A;
int M = A[rng() % sz(A)]; vi L, R;
for(auto& x : A) if (x != M) {
if (!is_clockwise(1, M + 1, x + 1)) L.pb(x);
else R.pb(x);
}
L = dnc(L); R = dnc(R);
L.pb(M);
L.insert(end(L), begin(R), end(R));
return L;
};
vi A(N - 1); iota(begin(A), end(A), 1);
A = dnc(A); A.insert(begin(A), 0);
// for(auto& x : A) cout << x << " ";
// cout << endl;
auto fix = [&](vi A) {
vi C = {A[0]};
for(int i = 1; i < sz(A); i++) {
while(sz(C) >= 2 && !is_clockwise(C[sz(C) - 2] + 1, C[sz(C) - 1] + 1, A[i] + 1)) C.pop_back();
C.pb(A[i]);
}
return C;
};
for(int i = 0; i < 5; i++) {
// cout << i << endl;
A = fix(A);
// for(auto& x : A) cout << x << " ";
// cout << endl;
rotate(begin(A), begin(A) + 1, end(A));
}
give_answer(sz(A));
exit(0-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... |