Submission #924779

#TimeUsernameProblemLanguageResultExecution timeMemory
924779boris_mihovXylophone (JOI18_xylophone)C++17
0 / 100
1 ms344 KiB
#include "xylophone.h" #include <algorithm> #include <iostream> #include <numeric> #include <cassert> #include <vector> #include <chrono> #include <random> typedef long long llong; const int MAXN = 5000 + 10; int a[MAXN]; void solve(int n) { int l = 1, r = n, mid; while (l < r - 1) { mid = (l + r) / 2; if (query(1, mid) < n - 1) l = mid; else r = mid; } a[r] = n; int idx = r; int last = 0; bool isMAX = true; for (int pos = r + 1 ; pos <= n ; ++pos) { int curr = query(idx, pos); if (curr == last) { pos--; isMAX ^= 1; idx = pos; continue; } if (isMAX) { a[pos] = a[idx] - curr; } else { a[pos] = a[idx] + curr; } last = curr; } idx = r; last = 0; isMAX = true; for (int pos = r - 1 ; pos >= 1 ; --pos) { int curr = query(pos, idx); if (curr == last) { pos++; isMAX ^= 1; idx = pos; continue; } if (isMAX) { a[pos] = a[idx] - curr; } else { a[pos] = a[idx] + curr; } last = curr; } for (int i = 1 ; i <= n ; ++i) { answer(i, a[i]); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...