# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
145449 | 2019-08-19T22:09:53 Z | faremy | Xylophone (JOI18_xylophone) | C++14 | 2 ms | 400 KB |
#include "xylophone.h" #include <iostream> #include <algorithm> static int A[5000]; const int MAXN = 5e3; int diff[MAXN]; int direction[MAXN]; int relAns[MAXN]; void solve(int N) { for (int i = 1; i < N; i++) diff[i - 1] = query(i, i + 1); direction[0] = 1; for (int i = 2; i < N; i++) { direction[i - 1] = direction[i - 2]; if (query(i - 1, i + 1) != diff[i - 2] + diff[i - 1]) direction[i - 1] *= -1; } for (int i = 1; i < N; i++) relAns[i] = relAns[i - 1] + diff[i - 1] * direction[i - 1]; if (query(1, N) != relAns[N - 1]) for (int i = 1; i < N; i++) relAns[i] *= -1; int min = 0; for (int i = 1; i < N; i++) min = std::min(min, relAns[i]); for (int i = 0; i < N; i++) answer(i + 1, relAns[i] - min + 1); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 400 KB | Output is correct |
2 | Incorrect | 2 ms | 376 KB | Wrong Answer [7 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 400 KB | Output is correct |
2 | Incorrect | 2 ms | 376 KB | Wrong Answer [7 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 400 KB | Output is correct |
2 | Incorrect | 2 ms | 376 KB | Wrong Answer [7 |
3 | Halted | 0 ms | 0 KB | - |