Submission #95995

#TimeUsernameProblemLanguageResultExecution timeMemory
95995diamond_dukeXylophone (JOI18_xylophone)C++11
0 / 100
2 ms404 KiB
#include "xylophone.h" int arr[5005], adj[5005], three[5005]; void solve(int n) { for (int i = 1; i < n; i++) adj[i] = query(i, i + 1); for (int i = 2; i < n; i++) three[i] = query(i - 1, i + 1); arr[0] = 0; arr[1] = adj[1]; for (int i = 2, dir = 1; i < n; i++) { if (three[i] != adj[i - 1] + adj[i]) dir ^= 1; arr[i] = arr[i - 1] + adj[i] * (dir * 2 - 1); } int mnp = 0, mxp = 0; for (int i = 0; i < n - 1; i++) { if (arr[i] < arr[mnp]) mnp = i; if (arr[i] > arr[mxp]) mxp = i; } for (int i = 0; i < n; i++) answer(i + 1, mnp < mxp ? arr[i] - arr[mnp] + 1 : arr[mxp] - arr[i] + 1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...