#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include "xylophone.h"
using namespace std;
const int MAX = 5002;
int a[MAX];
void solve(int n) {
for (int i = 2; i <= n; i++) {
int x = query(1, i);
int y = query(i - 1, i);
if (abs(a[i - 1] + y) == x) a[i] = a[i - 1] + y;
else a[i] = a[i - 1] - y;
}
int u = 0;
a[0] = INT_MIN;
for (int i = 1; i <= n; i++) {
if (a[i] > a[u]) u = i;
}
int v = 0;
a[0] = INT_MAX;
for (int i = 1; i <= n; i++) {
if (a[i] < a[v]) v = i;
}
if (u > v) {
for (int i = 1; i <= n; i++) {
answer(i, n - a[u] + a[i]);
}
} else {
for (int i = 1; i <= n; i++) {
answer(i, (n + 1) - (n - a[u] + a[i]));
}
}
}
/*int main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
solve();
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
1 ms |
348 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
1 ms |
348 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
1 ms |
348 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |