QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#263295 | #7833. Binary String | kkkgjyismine4 | WA | 175ms | 7484kb | C++14 | 956b | 2023-11-24 18:30:46 | 2023-11-24 18:30:47 |
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(){
mt19937 rnd(time(0));
for(int i=1;i<=N;){
int d=S/2+rnd()%(S/2+1);
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: 175ms
memory: 7484kb
input:
1 1 2 1 5 3 1 7 5 4 4 1 5 1 1 2 0 3 0 2 6 3 10 3 4 0 1 2 1 2 6 2 5 0 9 5 0 1 1 1 4 1 1 0 2 5 1 0 3 0 2 2 2 6 9 1 0 0 0 3 3 1 8 0 2 0 1 1 1 2 1 0 1 1 5 2 1 1 1 1 1 1 2 0 1 1 1 0 1 1 0 1 2 0 3 4 0 1 3 5 6 6 0 0 0 1 1 4 6 1 2 5 0 2 1 4 4 4 4 5 8 1 1 3 1 5 3 4 0 0 1 2 0 2 3 3 0 0 1 4 2 1 0 0 1 1 1 0 2 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 ? 2 2 ? 2 3 ? 2 4 ? 2 5 ? 2 6 ? 2 7 ? 2 8 ? 2 9 ? 2 10 ? 2 11 ? 2 12 ? 2 13 ? 3 3 ? 3 4 ? 3 5 ? 3 6 ? 3 7 ? 3 8 ? 3 9 ? 3 10 ? 3 11 ? 3 12 ? 3 13 ? 4 4 ? 4 5 ? 4 6 ? 4 7 ? 4 8 ? 4 9 ? 4 10 ? 4 11 ? 4 12 ? 4 13 ? 5 5 ? ...
result:
wrong answer 1-st bit is incorrect. Expected 1, found: 0