Submission #702836

#TimeUsernameProblemLanguageResultExecution timeMemory
702836HalogenXylophone (JOI18_xylophone)C++14
100 / 100
102 ms432 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; int ans[5005]; int diff[5005]; void solve(int N) { diff[1] = query(1, 2); int cur = diff[1]; int mini = 0, maxi = cur; bool check = true; for (int i = 2; i < N; ++i) { int res = query(i, i + 1); if (res + abs(diff[i - 1]) == query(i - 1, i + 1)) { if (diff[i - 1] < 0) diff[i] = -res; else diff[i] = res; } else { if (diff[i - 1] > 0) diff[i] = -res; else diff[i] = res; } cur += diff[i]; if (mini > cur) check = false, mini = cur; else if (maxi < cur) check = true, maxi = cur; } int offset = 1 - mini; if (!check) offset = 1 + maxi; cur = offset; for (int i = 1; i <= N; i++) { answer(i, cur); if (!check) cur -= diff[i]; else cur += diff[i]; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...