#include <xylophone.h>
void solve (int n) {
int a[n], d1[n], d2[n];
for (int i = 0; i < n - 1; i++)
d1[i] = query(i + 1, i + 2);
for (int i = 0; i < n - 2; i++)
d2[i] = query(i + 1, i + 3);
a[0] = 0, a[1] = d1[0];
bool tmp = 1;
for (int i = 2; i < n; i++) {
tmp = 1 - (d1[i - 2] + d1[i - 1] != d2[i - 2]);
a[i] = a[i - 1] + (tmp ? +1 : -1) * d1[i - 1];
}
int mx = 0, mxi = 0, mi = 0, mii = 0;
for (int i = 0; i < n; i++) {
if (a[i] > mx)
mx = a[i], mxi = i;
if (a[i] < mi)
mi = a[i], mii = i;
}
if (mii < mxi) {
for (int i = 0; i < n; i++)
answer(i + 1, a[i] - mi + 1);
}
else {
for (int i = 0; i < n; i++)
answer(i + 1, mx - a[i] + 1);
}
return ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
328 KB |
Output is correct |
3 |
Incorrect |
2 ms |
392 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
328 KB |
Output is correct |
3 |
Incorrect |
2 ms |
392 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
328 KB |
Output is correct |
3 |
Incorrect |
2 ms |
392 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |