QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#105591 | #6303. Inversion | LYC_music# | WA | 381ms | 3552kb | C++14 | 1.7kb | 2023-05-14 14:41:10 | 2023-05-14 14:41:13 |
Judging History
answer
#include<bits/stdc++.h>
#define poly vector<int>
#define IOS ios::sync_with_stdio(false)
#define ll long long
#define mp make_pair
#define mt make_tuple
#define pa pair < int,int >
#define fi first
#define se second
#define inf 1e18
#define mod 998244353
#define int ll
#define N 2005
using namespace std;
int n,a[N],p[N];
poly g;
mt19937_64 rnd(time(0));
int ansp[N];
int bl[N][N],vis[N][N];
int lim;
int tot=0;
int np[N];
namespace BIT
{
int tr[N];
void upd(int x,int y)
{
while (x<N)
{
tr[x]^=y;
x+=x&-x;
}
}
int qry(int x)
{
int res=0;
while (x)
{
res^=tr[x];
x-=x&-x;
}
return res;
}
}
using namespace BIT;
int query(int l,int r)
{
if (l>r) return 0;
int res=0;
if (r<lim)
{
for (auto u:g)
np[u]=p[u];
for (auto u:g)
if (np[np[u]]!=np[u])
{
res^=1;
swap(np[u],np[np[u]]);
}
return res;
}
cout<<"? "<<l<<" "<<r<<endl;
cin>>res;
return res;
}
void BellaKira()
{
cin>>n;
g.push_back(1);
for (int i=2;i<=n;i++)
{
lim=i;
int l=0,r=g.size()-1;
int x=0;
while (l<=r)
{
int mid=l+(r-l)/2;
if ((query(g[mid],i)-query(g[mid]+1,i)-query(g[mid],i-1)+query(g[mid]+1,i-1))%2==0)
{
x=mid+1;
l=mid+1;
} else r=mid-1;
}
poly nxt;
for (int j=0;j<x;j++) nxt.push_back(g[j]);
nxt.push_back(i);
for (int j=x;j<g.size();j++)
nxt.push_back(g[j]);
nxt.swap(g);
for (int j=0;j<g.size();j++)
p[g[j]]=j+1;
}
for (int i=0;i<n;i++)
p[g[i]]=i+1;
cout<<"! ";
for (int i=1;i<=n;i++) cout<<p[i]<<" ";
cout<<endl;
// cout<<tot<<endl;
// for (int i=1;i<=n;i++) assert(ansp[i]==p[i]);
}
signed main()
{
// IOS;
// cin.tie(0);
int T=1;
while (T--)
{
BellaKira();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3420kb
input:
3 0 0 0 1
output:
? 1 2 ? 2 2 ? 1 3 ? 2 3 ! 2 3 1
result:
ok OK, guesses=4
Test #2:
score: -100
Wrong Answer
time: 381ms
memory: 3552kb
input:
1993 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 1 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 1 1 1 1 1 1 1 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1 1 1 0 1 1 0 1 1 1 1 1 0 1 0 0 0 1 0 1 0 1 1 0 1 0 0 0 1 0 0 1 0 0 0 0 0 1 1 1 1 1 1 0 0 1 0 0 0 0 0 0 0 1 0 0 1 0 1 1 0 1 1 1 0 1 0 1 0 0 1 0 0 0 0 1...
output:
? 1 2 ? 2 2 ? 1 3 ? 2 3 ? 2 3 ? 3 3 ? 2 4 ? 3 4 ? 3 4 ? 4 4 ? 2 5 ? 3 5 ? 1 5 ? 2 5 ? 2 6 ? 3 6 ? 3 6 ? 4 6 ? 4 6 ? 5 6 ? 2 7 ? 3 7 ? 5 7 ? 6 7 ? 2 8 ? 3 8 ? 5 8 ? 6 8 ? 7 8 ? 8 8 ? 1 9 ? 2 9 ? 8 9 ? 9 9 ? 5 9 ? 6 9 ? 1 10 ? 2 10 ? 3 10 ? 4 10 ? 4 10 ? 5 10 ? 6 10 ? 7 10 ? 1 11 ? 2 11 ? 4 11 ? 5 11 ...
result:
wrong answer Wa.