QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#263292#7833. Binary Stringkkkgjyismine4WA 136ms7596kbC++14954b2023-11-24 18:26:102023-11-24 18:26:10

Judging History

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

  • [2023-11-24 18:26:10]
  • 评测
  • 测评结果:WA
  • 用时:136ms
  • 内存:7596kb
  • [2023-11-24 18:26:10]
  • 提交

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)<=(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: 136ms
memory: 7596kb

input:

1
1
2
1
5
3
1
7
1
1
1
1
2
2
3
1
0
1
3
3
6
0
0
1
4
0
1
1
0
1
1
2
3
1
1
0
1
0
1
0
2
3
5
6
5
8
1
1
3
4
2
3
4
5
6
0
0
0
2
2
4
4
5
1
2
2
2
3
1
5
1
0
2
3
5
5
0
1
2
2
4
1
2
3
1
0
0
2
0
2
0
1
1
0
3
3
2
2
3
4
8
6
12
8
1
0
2
4
1
4
0
3
9
4
6
7
0
0
0
1
4
2
7
2
5
6
3
1
1
1
0
2
3
4
0
8
8
1
0
1
4
3
4
1
6
7
0
2
0
2...

output:

? 1 1
? 1 2
? 1 3
? 1 4
? 1 5
? 1 6
? 1 7
? 1 8
? 2 2
? 2 3
? 2 4
? 2 5
? 2 6
? 2 7
? 2 8
? 3 3
? 3 4
? 3 5
? 3 6
? 3 7
? 3 8
? 4 4
? 4 5
? 4 6
? 4 7
? 4 8
? 5 5
? 5 6
? 5 7
? 5 8
? 6 6
? 6 7
? 6 8
? 7 7
? 7 8
? 8 8
? 9 9
? 9 10
? 9 11
? 9 12
? 9 13
? 9 14
? 9 15
? 9 16
? 9 17
? 9 18
? 10 10
? 10 11...

result:

wrong answer 2-nd bit is incorrect. Expected 0, found: 1