#include <bits/stdc++.h>
#include "xylophone.h"
using namespace std;
const int MAXN = 1e4 + 5;
int qry[MAXN][2];
int a[MAXN];
set<int> tmp;
bool finish = 0;
void detect_pitch(int n) {
int mi = 0, fl = 0;
for (int i = 0; i < n; i++)
mi = min(mi, a[i]);
for (int i = 0; i < n; i++) {
a[i] -= mi;
if (a[i] == n - 1 && !fl)
return;
if (a[i] == 0)
fl = 1;
}
for (int i = 0; i < n; i++)
answer(i+1, a[i]);
finish = 1;
}
void solve(int n) {
for (int i = 0; i + 1 < n; i++)
qry[i][0] = query(i, i + 1);
for (int i = 0; i + 2 < n; i++)
qry[i][1] = query(i, i + 2);
a[1] = qry[0][0];
tmp.insert(0);
tmp.insert(a[1]);
for (int i = 2; i < n; i++) {
if (qry[i - 2][0] == qry[i - 2][1]) {
int fl = 1;
if (a[i - 1] > a[i - 2])
fl = -1;
a[i] = a[i - 1] + fl * qry[i - 1][0];
} else if (qry[i - 2][0] + qry[i - 1][0] == qry[i - 2][1]) {
int fl = 1;
if (a[i - 1] < a[i - 2])
fl = -1;
a[i] = a[i - 1] + fl * qry[i - 1][0];
} else {
int fl = 1;
if (a[i - 1] > a[i - 2])
fl = -1;
a[i] = a[i - 1] + fl * qry[i - 1][0];
}
tmp.insert(a[i]);
}
if ((int)tmp.size() == n)
detect_pitch(n);
if (finish)
return;
for (int i = 0; i < n; i++)
a[i] = 0;
tmp.clear();
a[1] = -qry[0][0];
tmp.insert(0);
tmp.insert(a[1]);
for (int i = 2; i < n; i++) {
if (qry[i - 2][0] == qry[i - 2][1]) {
int fl = 1;
if (a[i - 1] > a[i - 2])
fl = -1;
a[i] = a[i - 1] + fl * qry[i - 1][0];
} else if (qry[i - 2][0] + qry[i - 1][0] == qry[i - 2][1]) {
int fl = 1;
if (a[i - 1] < a[i - 2])
fl = -1;
a[i] = a[i - 1] + fl * qry[i - 1][0];
} else {
int fl = 1;
if (a[i - 1] > a[i - 2])
fl = -1;
a[i] = a[i - 1] + fl * qry[i - 1][0];
}
tmp.insert(a[i]);
}
if ((int)tmp.size() == n)
detect_pitch(n);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Wrong Answer [1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Wrong Answer [1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Wrong Answer [1] |
2 |
Halted |
0 ms |
0 KB |
- |