#include "xylophone.h"
#include<bits/stdc++.h>
using namespace std;
void solve(int N) {
vector<int> v(N+1, 0);
int l = 0, r = N, one = N;
while(l<=r) {
int mid = (l+r)>>1;
if(query(mid, N) == N-1) {
one = mid;
l = mid+1;
}
else {
r = mid - 1;
}
}
v[one] = 1;
for(int i = one + 1; i<=N;i++) {
int val = query(i-1, i);
if(v[i-1] + val > N) {
v[i] = v[i-1] - val;
}
else {
v[i] = v[i-1] + val;
}
}
for(int i = one-1;i>0;i--) {
int val = query(i + 1, i);
if(v[i+1] + val > N) {
v[i] = v[i+1] -val;
}
else {
v[i] = v[i-1] + val;
}
}
for(int i = 1;i<=N;i++) {
answer(i, v[i]);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Incorrect |
2 ms |
200 KB |
Wrong Answer [1] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Incorrect |
2 ms |
200 KB |
Wrong Answer [1] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Incorrect |
2 ms |
200 KB |
Wrong Answer [1] |
4 |
Halted |
0 ms |
0 KB |
- |