#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
int n, root, a[5008], dis[5008][5008];
void solve(int N) {
n = N;
for (int i = 1; i < n; i++)
a[i] = query(i, i + 1);
for (int i = 1, j = 1; i + 2 <= n; i++){
int tmp = query(i, i + 2);
if (tmp != a[i] + a[i + 1])
j *= -1;
a[i + 1] *= j;
}
for (int i = 1; i <= n; i++){
int cnt = 0;
for (int j = i + 1; j <= n; j++){
dis[i][j] = dis[i][j - 1] + a[j - 1];
if (dis[i][j] > 0)
cnt++;
}
for (int j = i - 1; j > 0; j--){
dis[i][j] = -dis[j][i];
}
if (!cnt || cnt + 1 == n){
root = i;
break;
}
}
for (int i = 1; i <= n; i++)
answer(i, abs(dis[root][i]) + 1);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Incorrect |
1 ms |
436 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Incorrect |
1 ms |
436 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Incorrect |
1 ms |
436 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |