# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
981350 | 2024-05-13T05:18:12 Z | Amaarsaa | Xylophone (JOI18_xylophone) | C++14 | 1 ms | 344 KB |
#include<bits/stdc++.h> #include "xylophone.h" using namespace std; int a[5002], ans[5002]; void solve(int N) { int ind, mid,i, s,x1, x2, p, n = N, lo, hi; int r, b[5005], c[5005], ens[5005]; ans[1] = 0; ans[2] = 0 + query(1, 2); r = ans[2]; int mx = ans[2]; for ( i = 3; i <= n; i ++) { s = query(i - 1, i); p = query(i - 2, i); b[i]= s; c[i] = p; x1 = ans[i - 1] - s; x2 = ans[i - 1] + s; if ( max(x1, max(ans[i - 1], ans[i - 2])) - min(x1, min(ans[i - 1], ans[i - 2])) == p) { ans[i] = x1; } if ( max(x2, max(ans[i - 1], ans[i - 2])) - min(x2, min(ans[i - 1], ans[i - 2])) == p) { ans[i] = x2; } mx = max(mx,ans[i]); } int j = 1, J = 1; for (i = 1; i <= n; i ++) { ens[i] = ans[i]= ans[i] + (n - mx); if ( ans[i] == n) j = i; if ( ans[i] == 1) J = i; } sort ( ens + 1, ens + n + 1); int can = 1; for (i =1; i <= n; i ++) if ( ens[i] != i) can = 0; if ( can && query(J, j) == n - 1) { // for (i = 1; i <= n; i ++) cout << ans[i] << " "; for (i = 1; i <= n; i ++) answer(i, ans[i]); return ; } ans[1] = 0; ans[2] = -r; mx = 0; for ( i = 3; i <= n; i ++) { s = b[i]; p = c[i]; x1 = ans[i - 1] - s; x2 = ans[i - 1] + s; if ( max(x1, max(ans[i - 1], ans[i - 2])) - min(x1, min(ans[i - 1], ans[i - 2])) == p) { ans[i] = x1; } if ( max(x2, max(ans[i - 1], ans[i - 2])) - min(x2, min(ans[i - 1], ans[i - 2])) == p) { ans[i] = x2; } mx = max(mx,ans[i]); } for (i = 1; i <= n; i ++) ans[i] = ans[i] + (n - mx); // for (i = 1; i <= n; i ++) cout << ans[i] << " "; for (i =1 ; i<= n; i++) answer(i, ans[i]); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 344 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 1 ms | 344 KB | Output is correct |
5 | Incorrect | 1 ms | 344 KB | Wrong Answer [1] |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 344 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 1 ms | 344 KB | Output is correct |
5 | Incorrect | 1 ms | 344 KB | Wrong Answer [1] |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 344 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 1 ms | 344 KB | Output is correct |
5 | Incorrect | 1 ms | 344 KB | Wrong Answer [1] |
6 | Halted | 0 ms | 0 KB | - |