QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#297893 | #6303. Inversion | PlentyOfPenalty# | WA | 29ms | 3488kb | C++20 | 763b | 2024-01-05 13:04:07 | 2024-01-05 13:04:07 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2011;
int a[MAXN];
int get(int l,int r)
{
if(l>=r)return 0;
cout<<"? "<<l<<" "<<r<<endl;
int x;
cin>>x;
return x;
}
void printans(int n)
{
cout<<"!";
for(int i=1;i<=n;++i)cout<<" "<<a[i];
cout<<endl;
}
bool less(int i,int j)
{
int all=get(i,j);
int t=get(i,j-1)^get(i+1,j)^get(i+1,j-1);
return all==t;
}
void solve(int l,int r)
{
if(l==r){a[l]=1;return;}
int mid=(l+r)>>1;
solve(l,mid),solve(mid+1,r);
int i=l,j=mid+1;
while(i<=mid&&j<=r)
{
if(::less(i,j))a[i]+=j-(mid+1), ++i;
else a[j]+=i-l,++j;
}
while(i<=mid)a[i]+=j-(mid+1),++i;
while(j<=r)a[j]+=i-l,++j;
}
int main()
{
int n;
cin>>n;
solve(1,n);
printans(n);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3392kb
input:
3 0 0 0 1
output:
? 1 2 ? 1 3 ? 1 2 ? 2 3 ! 2 3 1
result:
ok OK, guesses=4
Test #2:
score: -100
Wrong Answer
time: 29ms
memory: 3488kb
input:
1993 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1 1 1 0 0 0 1 0 0 0 0 1 0 0 1 0 0 0 1 1 1 1 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 1 1 1 1 0 1 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 1 0 1 0 0 0 1 0 0 1...
output:
? 1 2 ? 3 4 ? 1 3 ? 1 2 ? 2 3 ? 2 3 ? 5 6 ? 7 8 ? 5 7 ? 5 6 ? 6 7 ? 5 8 ? 5 7 ? 6 8 ? 6 7 ? 6 8 ? 6 7 ? 7 8 ? 1 5 ? 1 4 ? 2 5 ? 2 4 ? 1 6 ? 1 5 ? 2 6 ? 2 5 ? 1 7 ? 1 6 ? 2 7 ? 2 6 ? 1 8 ? 1 7 ? 2 8 ? 2 7 ? 2 8 ? 2 7 ? 3 8 ? 3 7 ? 3 8 ? 3 7 ? 4 8 ? 4 7 ? 9 10 ? 11 12 ? 9 11 ? 9 10 ? 10 11 ? 9 12 ? 9 ...
result:
wrong output format Unexpected end of file - int32 expected