QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#263284#7833. Binary Stringkkkgjyismine4WA 210ms7744kbC++14835b2023-11-24 18:19:132023-11-24 18:19:13

Judging History

你现在查看的是最新测评结果

  • [2023-11-24 18:19:13]
  • 评测
  • 测评结果:WA
  • 用时:210ms
  • 内存:7744kb
  • [2023-11-24 18:19:13]
  • 提交

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;
	    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)<=2){
	    	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: 210ms
memory: 7744kb

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
0
1
1
3
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