# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
92795 | 2019-01-04T20:13:24 Z | Alexa2001 | Xylophone (JOI18_xylophone) | C++17 | 2 ms | 376 KB |
#include "xylophone.h" #include<bits/stdc++.h> using namespace std; const int Nmax = 5005; static int A[Nmax], B[Nmax], x[Nmax]; void solve(int N) { int i; for(i=1; i<=N-1; ++i) A[i] = query(i, i+1); for(i=1; i<=N-2; ++i) B[i] = query(i, i+2); x[1] = 0; x[2] = A[1]; for(i=3; i<=N; ++i) if(x[i-2] < x[i-1]) { if(B[i-2] == A[i-2]) /// middle value x[i] = x[i-1] - A[i-1]; else if(A[i-1] == B[i-2]) /// smallest value x[i] = x[i-1] - A[i-1]; else x[i] = x[i-1] + A[i-1]; /// greatest value } else { if(B[i-2] == A[i-2]) /// middle x[i] = x[i-1] + A[i-1]; else if(A[i-1] == B[i-2]) /// greatest x[i] = x[i-1] + A[i+1]; else x[i] = x[i-1] - A[i-1]; } int Min = 0; for(i=1; i<=N; ++i) Min = min(Min, x[i]); for(i=1; i<=N; ++i) x[i] -= Min - 1; int id1, idn; for(i=1; i<=N; ++i) if(x[i] == 1) id1 = i; else if(x[i] == N) idn = i; if(id1 > idn) for(i=1; i<=N; ++i) x[i] = N + 1 - x[i]; for(i=1; i<=N; ++i) answer(i, x[i]); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 304 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Incorrect | 2 ms | 248 KB | Wrong Answer [4] |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 304 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Incorrect | 2 ms | 248 KB | Wrong Answer [4] |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 304 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Incorrect | 2 ms | 248 KB | Wrong Answer [4] |
4 | Halted | 0 ms | 0 KB | - |