#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
const long long maxn=2e5+5;
const long long logn=23;
void solve(int n) {
bool vis[n+1];
memset(vis,0,sizeof vis);
int l=1;
int r=n-1;
int raz=n-1;
while(true)
{
int k=query(l,r);
if(k==raz)
{
r--;
}
else
{
r++;
break;
}
}
while(true)
{
int k=query(l,r);
if(k==raz)
{
l++;
}
else
{
l--;
break;
}
}
int s=l;
int e=r;
answer(l,1);
answer(r,n);
vis[1]=1;
vis[n]=1;
int p=1;
for(int i=s-1;i>=1;i--)
{
int k=query(i,i+1);
if(p==1)
{
answer(i,k+p);
vis[k+p]=1;
p+=k;
}
else
{
if(k+p<=n)
{
if(p-k<1)
{
answer(i,k+p);
vis[k+p]=1;
p+=k;
}
else
{
int kolku=query(i,s);
if(p==1+kolku)
{
answer(i,p-k);
vis[p-k]=1;
p-=k;
}
else
{
answer(i,k+p);
vis[k+p]=1;
p+=k;
}
}
}
else
{
answer(i,p-k);
vis[p-k]=1;
p-=k;
}
}
}
p=1;
for(int i=s+1;i<e;i++)
{
int k=query(i-1,i);
if(p==1)
{
answer(i,k+p);
vis[k+p]=1;
p+=k;
}
else
{
if(k+p<=n)
{
if(p-k<1)
{
answer(i,k+p);
vis[k+p]=1;
p+=k;
}
else
{
int kolku=query(s,i);
if(p==1+kolku)
{
answer(i,p-k);
vis[p-k]=1;
p-=k;
}
else
{
answer(i,k+p);
vis[k+p]=1;
p+=k;
}
}
}
else
{
answer(i,p-k);
vis[p-k]=1;
p-=k;
}
}
}
p=n;
for(int i=e+1;i<=n;i++)
{
int k=query(i-1,i);
if(p==n)
{
answer(i,p-k);
vis[p-k]=1;
p-=k;
}
else
{
if(k+p<=n)
{
if(p-k<1)
{
answer(i,k+p);
vis[k+p]=1;
p+=k;
}
else
{
int kolku=query(e,i);
if(p==n-kolku)
{
answer(i,p+k);
vis[p+k]=1;
p+=k;
}
else
{
answer(i,k-p);
vis[k-p]=1;
p-=k;
}
}
}
else
{
answer(i,p-k);
vis[p-k]=1;
p-=k;
}
}
}
// query(1, 50); answer(2, 1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
0 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 |
0 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 |
- |