Submission #958303

#TimeUsernameProblemLanguageResultExecution timeMemory
958303JwFXoizXylophone (JOI18_xylophone)C++14
0 / 100
1 ms600 KiB
#include <bits/stdc++.h> #include "xylophone.h" using namespace std; void solve(int N) { int l = 1, r = N; while (l < r) { int mid = (l + r + 1) >> 1; if (query(mid, N) == N - 1) l = mid; else r = mid - 1; } int a[N + 1]; a[l] = 1; int up = 1, last = -1, p = l; for (int i = l + 1; i <= N; i++) { int x = query(p, i); if (x == last) { p = i - 1, up ^= 1; x = query(p, i); } last = x; if (up) a[i] = a[p] + x; else a[i] = a[p] - x; } up = 1, last = -1, p = l; for (int i = l - 1; i >= 1; i--) { int x = query(i, p); if (x == last) { p = i + 1, up ^= 1; x = query(i, p); } last = x; if (up) a[i] = a[p] + x; else a[i] = a[p] - x; } 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...