QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#263327#7833. Binary StringzqsWA 159ms8728kbC++141.4kb2023-11-24 19:03:362023-11-24 19:03:38

Judging History

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

  • [2023-11-24 19:03:38]
  • 评测
  • 测评结果:WA
  • 用时:159ms
  • 内存:8728kb
  • [2023-11-24 19:03:36]
  • 提交

answer

#include <cstdio>
#include <cstring>
#include <random>
#include <ctime>

std::mt19937 rnd(time(NULL));
int adjust(int x) {
	if (x <= 0) x = 0;
	else x = 1;
	return x;
}
int sum[1005][1005], real[1005][1005], buc[1005], n = 1000, m = 500;
int a[1005],ans[1005];
bool vis[1005][1005];
inline bool ask(int l, int r) {
	if (!vis[l][r]) {
		printf("? %d %d\n", l, r);
		fflush(stdout);
//		if(rnd()&1)sum[l][r]=a[r]-a[l-1];
//		else sum[l][r]=(rnd()%(r-l+2)+(r-l+2))%(r-l+2);
		scanf("%d", &sum[l][r]);
		vis[l][r] = true;
	}
	return sum[l][r];
}

int main() {
//	for(int i=1;i<=n;++i)a[i]=a[i-1]+rnd()%2;
	for (int len = m - 1; len <= m; ++ len) {
		for (int i = 1; i + len - 1 <= n; ++ i) {
			memset(buc, 0, sizeof buc);
			int j = i + len - 1;
			for (int k = i; k < j && k <= i + 160; ++ k) {
				ask(i, k), ask(k + 1, j);
				if (sum[i][k] + sum[k + 1][j] <= j - i + 1) ++ buc[sum[i][k] + sum[k + 1][j]];
			}
			int major = 0;
			for (int k = 1; k <= j - i + 1; ++ k) if (buc[k] > buc[major]) major = k;
			real[i][j] = major;
		}
	}
	printf("! ");
	for (int i = 1; i <= n; ++ i) {
		if (i <= n - m + 1) printf("%d", ans[i] = adjust(real[i][i + m - 1] - real[i + 1][i + m - 1]));
		else printf("%d", ans[i] = adjust(real[i - m + 1][i] - real[i - m + 1][i - 1]));
	}
	puts("");
//	for(int i=1;i<=n;++i)if(ans[i]!=a[i]-a[i-1])return printf("wrong at %d\n",i), 0;
	fflush(stdout);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 159ms
memory: 8728kb

input:

1
250
1
360
1
120
4
192
4
248
0
248
3
78
3
42
2
57
9
136
5
247
4
448
5
246
14
385
6
245
7
420
8
324
9
242
15
95
0
329
10
241
10
241
19
240
11
277
17
240
26
239
13
230
12
163
15
386
16
235
15
329
26
234
17
234
17
234
17
9
18
233
9
336
19
296
19
428
20
231
20
231
21
358
22
229
36
228
24
140
24
437
24
...

output:

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

result:

wrong output format Unexpected end of file - token expected