#include <bits/stdc++.h>
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#include "xylophone.h"
typedef long long ll;
using namespace std;
const int M = 5e3 + 1;
int a[M];
pair<int, int> g[M];
void solve2(int n) {
map<int, int> d;
d[0] = 1;
d[a[1]] = 2;
for (int i = 3; i <= n; i++) {
int x = g[i].ff, y = g[i].ss;
int r = abs(a[i - 2] - a[i - 1]);
if (a[i - 2] < a[i - 1]) {
if (x != r && x != y) a[i] = a[i - 2] + x;
else a[i] = a[i - 1] - y;
}
else {
if (x != r && x != y) a[i] = a[i - 2] - x;
else a[i] = a[i - 1] + y;
}
if (d[a[i]]) return;
d[a[i]] = i;
}
int i = 1;
for (auto [x, y] : d) {
answer(y, i);
i++;
}
exit(0);
}
void solve(int N) {
for (int i = 3; i <= N; i++) {
g[i].ff = query(i - 2, i);
g[i].ss = query(i - 1, i);
}
a[1] = 0;
a[2] = query(1, 2);
solve2(N);
a[2] *= -1;
solve2(N);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |