#include<bits/stdc++.h>
#include "xylophone.h"
using namespace std;
static int A[5000];
void solve(int N) {
int l=1,r=N,mid,i,mx=1,idx=0;
while(r>l){
mid=(r+l+1)/2;
if(query(mid,N)==N-1) l=mid;
else r=mid-1;
}
answer(l,1);
for(i=l+1;i<=N;i++){
int x=query(l,i),y;
if(x>=mx){
answer(i,x+1);
mx=x+1;
idx=i;
}
else{
y=query(idx,i);
answer(i,mx-y);
}
}
mx=1;
idx=0;
for(i=l-1;i>=1;i--){
int x=query(i,l),y;
if(x>=mx){
answer(i,x+1);
mx=x+1;
idx=i;
}
else{
y=query(i,idx);
answer(i,mx-y);
}
}
}
Compilation message
xylophone.cpp:4:12: warning: 'A' defined but not used [-Wunused-variable]
4 | static int A[5000];
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |