#include <bits/stdc++.h>
using namespace std;
int query(int,int);
void answer(int,int);
void solve(int N){
vector<int> diffs(N+1,0);
for(int i = 1;i<=N-1;++i){
diffs[i] = query(i,i+1);
}
vector<int> nums(N+1,0);
int dir = 1; nums[2] = diffs[1];
for(int i = 1;i<=N-2;++i){
int val = query(i,i+2);
if(val == diffs[i]+diffs[i+1]){ //same direction
nums[i+2] = nums[i+1]+dir*diffs[i+1];
}
else{
dir = (-1)*dir;
nums[i+2] = nums[i+1]+dir*diffs[i+1];
}
}
int minn = 0, maxx = 0;
for(int i = 2;i<=N;++i){
minn = min(minn,nums[i]);
maxx = max(maxx,nums[i]);
}
if(maxx+1-minn > N){
for(int i = 2;i<=N;++i){
nums[i] = (-1)*nums[i];
}
}
for(int i = 1;i<=N;++i){
nums[i] += 1-minn;
answer(i,nums[i]);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Incorrect |
1 ms |
344 KB |
Wrong Answer [7] |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Incorrect |
1 ms |
344 KB |
Wrong Answer [7] |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Incorrect |
1 ms |
344 KB |
Wrong Answer [7] |
6 |
Halted |
0 ms |
0 KB |
- |