Submission #971564

#TimeUsernameProblemLanguageResultExecution timeMemory
971564IBoryXylophone (JOI18_xylophone)C++17
100 / 100
67 ms1200 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; const int MAX = 5005; int A[MAX]; void solve(int N) { A[2] = query(1, 2); for (int i = 3; i <= N; ++i) { int d1 = query(i - 1, i); int d2 = query(i - 2, i); if (abs(A[i - 1] - A[i - 2]) + d1 == d2) { if (A[i - 2] < A[i - 1]) A[i] = A[i - 1] + d1; else A[i] = A[i - 1] - d1; } else { if (A[i - 2] < A[i - 1]) A[i] = A[i - 1] - d1; else A[i] = A[i - 1] + d1; } } int off = *min_element(A + 1, A + N + 1); for (int i = 1; i <= N; ++i) A[i] = A[i] - off + 1; if (min_element(A + 1, A + N + 1) - max_element(A + 1, A + N + 1) > 0) { for (int i = 1; i <= N; ++i) A[i] = N + 1 - A[i]; } 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...