#include<bits/stdc++.h>
#include "xylophone.h"
using namespace std;
int a[5001];
void ask(int x, int y, int z){
int v1=abs(a[x]-a[y]), v2=query(min(y, z), max(y, z)), v3=query(min(x, z), max(x, z));
if (v1!=v3){
if (a[x]<a[y]){
if (v2==v3) a[z]=a[y]-v2;
else a[z]=a[y]+v2;
}else{
if (v2==v3) a[z]=a[y]+v2;
else a[z]=a[y]-v2;
}
}else{
if (a[x]<a[y]) a[z]=a[y]-v2;
else a[z]=a[y]+v2;
}
}
void solve(int N){
int l=2, r=N;
while (l<=r){
int mid=(l+r)>>1ll;
if (query(1, mid)==N-1) r=mid-1;
else l=mid+1;
}
a[l]=N;
for (int i=l+1; i<=N; ++i){
if (i==l+1) a[i]=N-query(l, l+1);
else ask(i-2, i-1, i);
}
for (int i=l-1; i>=1; --i){
if (i==l-1) a[i]=N-query(l-1, l);
else ask(i+2, i+1, i);
}
for (int i=1; i<=N; ++i) cout << a[i] << " \n"[i==N];
for (int i=1; i<=N; ++i) answer(i, a[i]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |