#include<bits/stdc++.h>
#include "xylophone.h"
using namespace std;
void solve(int n) {
// int value = query(1, N);
// for(int i = 1; i <= N; i++) {
// answer(i, i);
// }
int arr[n];
int barr[n];
int dir[n];
for(int i=0; i<n-1; i++){
arr[i]=query(i+1, i+2);
}
for(int i=0; i<n-2; i++){
barr[i]=query(i+1, i+3);
}
dir[0]=1;
for(int i=0; i<n-2; i++){
if(barr[i]==max(arr[i], arr[i+1])){
dir[i+1]=-dir[i];
}
else{
dir[i+1]=dir[i];
}
}
int ans[n];
ans[0]=0;
for(int i=1; i<n; i++){
ans[i]=ans[i-1]+arr[i-1]*dir[i-1];
}
int minn = 1000000;
for(int i=0; i<n; i++){
minn = min(minn, ans[i]);
}
for(int i=0; i<n; i++){
ans[i]+=minn+1;
}
bool res = false;
for(int i=0; i<n; i++){
if(ans[i]==n){
res = true;
break;
}
else if(ans[i]==1){
break;
}
}
if(res==true){
for(int i=0; i<n; i++){
ans[i] = n+1-ans[i];
}
}
for(int i=0; i<n; i++){
answer(i+1, ans[i]);
}
return;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Incorrect |
1 ms |
208 KB |
Wrong Answer [4] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Incorrect |
1 ms |
208 KB |
Wrong Answer [4] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Incorrect |
1 ms |
208 KB |
Wrong Answer [4] |
4 |
Halted |
0 ms |
0 KB |
- |