QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#263280 | #7833. Binary String | kkkgjyismine4 | WA | 450ms | 7536kb | C++14 | 773b | 2023-11-24 18:16:38 | 2023-11-24 18:16:38 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int ans[1003],qry[1003][1003];
const int S=15,N=1000;
int sum[1003];
int query(int l,int r){
cout<<"? "<<l<<" "<<r<<endl;
int num;cin>>num;return num;
}
void solve(int l,int r){
for(int i=l;i<=r;++i)
for(int j=i;j<=r;++j)qry[i][j]=query(i,j);
for(int i=0;i<(1<<r-l+1);++i){
sum[l-1]=0;
for(int j=0;j<r-l+1;++j)sum[l+j]=sum[l+j-1]+((i>>j)&1);
int cnt=0;
for(int a=l;a<=r;++a)for(int b=a;b<=r;++b)if(qry[a][b]==sum[b]-sum[a-1])++cnt;else --cnt;
if(abs(cnt)<=1){
for(int j=0;j<r-l+1;++j)ans[l+j]=((i>>j)&1);
return;
}
}
}
int main(){
for(int i=1;i<=N;i+=S)solve(i,min(i+S-1,N));cout<<"! ";
for(int i=1;i<=N;++i)putchar(ans[i]+'0');cout<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 450ms
memory: 7536kb
input:
1 1 2 1 5 3 1 7 5 4 4 1 5 0 6 1 1 3 3 3 6 2 7 3 3 11 12 5 5 1 2 0 2 2 5 1 2 6 3 4 5 13 0 1 3 1 5 1 2 6 1 6 4 1 1 1 3 4 2 2 2 2 3 4 4 1 2 0 2 1 3 1 2 3 3 1 0 0 1 5 1 5 3 3 0 1 1 4 1 2 1 8 1 2 0 2 2 2 3 1 2 0 2 3 0 1 2 1 2 4 0 0 0 1 1 1 1 1 2 0 0 2 1 4 4 4 4 5 8 5 4 7 11 11 10 1 0 0 0 3 1 4 4 4 8 10 1...
output:
? 1 1 ? 1 2 ? 1 3 ? 1 4 ? 1 5 ? 1 6 ? 1 7 ? 1 8 ? 1 9 ? 1 10 ? 1 11 ? 1 12 ? 1 13 ? 1 14 ? 1 15 ? 2 2 ? 2 3 ? 2 4 ? 2 5 ? 2 6 ? 2 7 ? 2 8 ? 2 9 ? 2 10 ? 2 11 ? 2 12 ? 2 13 ? 2 14 ? 2 15 ? 3 3 ? 3 4 ? 3 5 ? 3 6 ? 3 7 ? 3 8 ? 3 9 ? 3 10 ? 3 11 ? 3 12 ? 3 13 ? 3 14 ? 3 15 ? 4 4 ? 4 5 ? 4 6 ? 4 7 ? 4 8 ...
result:
wrong answer 9-th bit is incorrect. Expected 0, found: 1