Submission #347268

#TimeUsernameProblemLanguageResultExecution timeMemory
347268maomao90Xylophone (JOI18_xylophone)C++14
100 / 100
127 ms492 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; #define REP(i, j, k) for (int i = j; i < k; i++) void solve(int n) { vector<int> a(n + 5, 0); if (n == 1) { answer(1, 1); return; } a[2] = a[1] + query(1, 2); int sign = a[2] > a[1] ? 1 : -1; REP (i, 3, n + 1) { int fi = query(i - 1, i), se = query(i - 2, i); if (abs(a[i - 1] - a[i - 2]) + fi != se) { sign = -sign; } a[i] = a[i - 1] + fi * sign; } int mn = 0; REP (i, 1, n + 1) mn = min(mn, a[i]); REP (i, 1, n + 1) a[i] -= mn; REP (i, 1, n + 1) { if (a[i] == 0) break; if (a[i] == n - 1) { REP (j, 1, n + 1) a[j] = n - a[j] - 1; break; } } REP (i, 1, n + 1) answer(i, a[i] + 1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...