Submission #130613

#TimeUsernameProblemLanguageResultExecution timeMemory
130613tutisXylophone (JOI18_xylophone)C++17
0 / 100
3 ms376 KiB
#include <bits/stdc++.h> #pragma GCC optimize ("O3") #include "xylophone.h" using namespace std; void solve(int N) { int A[N + 1]; A[1] = 0; A[2] = A[1] + query(1, 2); for (int i = 3; i <= N; i++) { int x = query(i - 1, i); int y = query(i - 2, i); if (A[i - 1] > A[i - 2]) { if (y == x + A[i - 1] - A[i - 2]) A[i] = A[i - 1] + x; else A[i] = A[i - 1] - x; } else { if (y == x + A[i - 2] - A[i - 1]) A[i] = A[i - 1] - x; else A[i] = A[i - 1] + x; } } auto it1 = min_element(A + 1, A + (N + 1)); auto itn = max_element(A + 1, A + (N + 1)); if (it1 > itn) { reverse(A + 1, A + (N + 1)); } int x = *min_element(A, A + (N + 1)); for (int i = 1; i <= N; i++) { A[i] -= x; A[i]++; answer(i, A[i]); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...