QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#263296 | #7833. Binary String | kkkgjyismine4 | WA | 705ms | 7276kb | C++14 | 916b | 2023-11-24 18:31:37 | 2023-11-24 18:31:37 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int ans[1003],qry[1003][1003];
const int S=16,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,mn=0,mx=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;
mn=min(mn,cnt);mx=max(mx,cnt);
}
bool flag=(abs(cnt)<=2);flag&=((mx-mn)<=2*(r-l+1));
if(flag){
for(int j=0;j<r-l+1;++j)ans[l+j]=((i>>j)&1);
return;
}
}
}
int main(){
for(int i=1;i<=N;){
int d=S;
solve(i,min(i+d-1,N));i+=d;
}
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: 705ms
memory: 7276kb
input:
1 1 2 1 5 3 1 7 5 4 4 1 5 0 6 6 0 0 0 1 2 2 0 2 3 0 7 4 5 5 4 1 0 2 2 5 3 3 5 3 3 4 0 5 6 1 0 1 0 1 1 5 4 1 3 8 4 5 0 1 1 1 1 2 2 6 3 4 3 2 0 2 0 2 1 1 1 2 3 2 4 0 1 0 0 1 3 2 3 3 8 0 1 1 1 5 6 5 4 6 1 1 0 1 1 5 3 4 1 2 0 2 3 3 2 1 0 3 2 4 2 0 2 2 4 3 0 2 2 3 1 0 2 1 2 1 1 0 0 0 3 1 4 4 4 8 10 10 0 ...
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 ? 1 16 ? 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 ? 2 16 ? 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 ? 3 16 ? 4 4 ? 4...
result:
wrong answer 16-th bit is incorrect. Expected 1, found: 0