QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#324992#8239. Mysterious Treeucup-team2000#WA 1ms3900kbC++20690b2024-02-11 02:47:402024-02-11 02:47:41

Judging History

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

  • [2024-02-11 02:47:41]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3900kb
  • [2024-02-11 02:47:40]
  • 提交

answer

#include <bits/stdc++.h>

int T, N;

int main() {
	scanf("%d", &T); while (T--) {
		scanf("%d", &N);
		int res = N - 1;
		for (int i = 1; i <= N - 2; i += 2) {
			printf("? %d %d\n", i, i + 1);
			fflush(stdout);
			int t;
			scanf("%d", &t);
			if (t == 1) {
				res = i;
				break;
			}
		}
		int a = 1, b = 2;
		if (res == 1) {
			a = 3, b = 4;
		}
		for (int i = res; i <= res + 1; ++i) {
			int t1, t2;
			printf("? %d %d\n", i, a);
			fflush(stdout);
			scanf("%d", &t1);
			printf("? %d %d\n", i, b);
			fflush(stdout);
			scanf("%d", &t2);
			if (t1 == 1 && t2 == 1) {
				printf("! 2\n");
				fflush(stdout);
				goto end;
			}
		}
		printf("! 1\n");
		fflush(stdout);
end:;
	}
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3776kb

input:

2
4
1
0
0
1
0
4
0
1
1

output:

? 1 2
? 1 3
? 1 4
? 2 3
? 2 4
! 1
? 1 2
? 3 1
? 3 2
! 2

result:

ok Correct (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3900kb

input:

87
13
0
0
0
0
0
1
0
0
1
1
15
0
0
0
0
0
0
1
1
1
7
0
0
0
0
0
1
1
15
0
0
0
1
0
0
0
0
19
0
0
0
0
0
1
1
1
20
0
0
0
0
0
0
0
0
0
0
0
1
0
7
0
0
1
0
0
1
1
20
0
0
0
0
0
0
0
1
1
1
17
0
0
0
0
0
0
0
0
1
0
0
0
11
1
0
0
0
1
14
0
0
0
0
0
0
0
0
1
0
13
0
0
0
0
0
0
0
0
0
0
18
0
0
0
0
0
1
0
0
1
1
14
0
1
0
0
1
1
20
0
0
...

output:

? 1 2
? 3 4
? 5 6
? 7 8
? 9 10
? 11 12
? 11 1
? 11 2
? 12 1
? 12 2
! 2
? 1 2
? 3 4
? 5 6
? 7 8
? 9 10
? 11 12
? 13 14
? 13 1
? 13 2
! 2
? 1 2
? 3 4
? 5 6
? 6 1
? 6 2
? 7 1
? 7 2
! 2
? 1 2
? 3 4
? 5 6
? 7 8
? 7 1
? 7 2
? 8 1
? 8 2
! 1
? 1 2
? 3 4
? 5 6
? 7 8
? 9 10
? 11 12
? 11 1
? 11 2
! 2
? 1 2
? 3...

result:

wrong answer Wrong prediction (test case 55)