// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <xylophone.h>
using namespace std;
// #define int long long
#define pb push_back
// #define endl '\n'
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define setmin(x,y) x=min((x),(y))
#define setmax(x,y) x=max((x),(y))
#define fi first
#define se second
mt19937 hdp(chrono::high_resolution_clock::now().time_since_epoch().count());
int rand(int l,int r){return l+((hdp()%(r-l+1))+r-l+1)%(r-l+1);}
const int N = 1e4+5;
const int mod = 998244353;
const int SQ = 450;
const int inf = 1e9+1;
int ans[N],n;
bool b[N];
bool check(int x)
{
if(x<0||x>n) return 0;
return !b[x];
}
// int query(int l,int r)
// {
// cout<<l<<' '<<r<<endl;
// int res; cin>>res; return res;
// }
void solve(int _n)
// signed main()
{
n=_n;
// cin>>n;
int l=1,r=n;
while(l<r-1)
{
int m=l+r>>1;
if(query(m,n)!=n-1) r=m;
else l=m;
}
ans[l]=1; b[1]=1;
if(l-1)
{
ans[l-1]=ans[l]+query(l-1,l);
b[ans[l-1]]=1;
}
if(l+1<=n)
{
ans[l+1]=ans[l]+query(l,l+1);
b[ans[l+1]]=1;
}
cout<<"LDSJFOLSJDF";
for(int i=l-2;i>=1;i--)
{
int t=query(i,i+1);
if(!check(ans[i+1]+t)) ans[i]=ans[i+1]-t;
else if(!check(ans[i+1]-t)) ans[i]=ans[i+1]+t;
if(!ans[i])
{
int tt=query(i,i+2);
if(tt==abs(ans[i+2]-ans[i+1]))
{
if(ans[i+2]>ans[i+1]) ans[i]=ans[i+1]+t;
else ans[i]=ans[i+1]-t;
}
else if(tt==t)
{
if(ans[i+2]>ans[i+1]) ans[i]=ans[i+1]+t;
else ans[i]=ans[i+1]-t;
}
else
{
if(ans[i+2]>ans[i+1]) ans[i]=ans[i+1]-t;
else ans[i]=ans[i+1]+t;
}
}
b[ans[i]]=1;
}
for(int i=l+2;i<=n;i++)
{
int t=query(i-1,i);
if(!check(ans[i-1]+t)) ans[i]=ans[i-1]-t;
else if(!check(ans[i-1]-t)) ans[i]=ans[i-1]+t;
if(!ans[i])
{
int tt=query(i-2,i);
if(tt==abs(ans[i-2]-ans[i-1]))
{
if(ans[i-2]>ans[i-1]) ans[i]=ans[i-1]+t;
else ans[i]=ans[i-1]-t;
}
else if(tt==t)
{
if(ans[i-2]>ans[i-1]) ans[i]=ans[i-1]+t;
else ans[i]=ans[i-1]-t;
}
else
{
if(ans[i-2]>ans[i-1]) ans[i]=ans[i-1]-t;
else ans[i]=ans[i-1]+t;
}
}
b[ans[i]]=1;
}
for(int i=1;i<=n;i++) answer(i,ans[i]);
// for(int i=1;i<=n;i++) cout<<ans[i]<<' ';
}
Compilation message
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:47:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
47 | int m=l+r>>1;
| ~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Expected integer, but "LDSJFOLSJDF1721" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Expected integer, but "LDSJFOLSJDF1721" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Expected integer, but "LDSJFOLSJDF1721" found |
2 |
Halted |
0 ms |
0 KB |
- |