Submission #918179

#TimeUsernameProblemLanguageResultExecution timeMemory
918179NK_Triangles (CEOI18_tri)C++17
0 / 100
1 ms348 KiB
// 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(1008); // 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(auto& x : C) cout << x << " "; // cout << endl; deque<int> D(begin(A), end(A)); while(1) { bool done = 1; int x = D.back(); D.pop_back(); if (!is_clockwise(D.back() + 1, x + 1, D.front() + 1)) done = 0; else D.pb(x); int y = D.front(); D.pop_front(); if (!is_clockwise(D.back() + 1, y + 1, D.front() + 1)) done = 0; else D.push_front(y); if (done) break; } // for(auto& x : D) cout << x << " "; // cout << endl; give_answer(sz(D)); exit(0-0); }

Compilation message (stderr)

tri.cpp: In function 'int main()':
tri.cpp:46:7: warning: variable 'fix' set but not used [-Wunused-but-set-variable]
   46 |  auto fix = [&](vi A) {
      |       ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...