QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#393356#8239. Mysterious Treeucup-team3282#WA 1ms3756kbC++142.0kb2024-04-18 15:34:422024-04-18 15:34:43

Judging History

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

  • [2024-04-18 15:34:43]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3756kb
  • [2024-04-18 15:34:42]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

int main() {
	//freopen("J.in", "r", stdin);
	int T; cin >> T;
	while (T--) {
		int n, cc = 0;
		cin >> n;	
		set<int> v;
		for (int i = 1; i <= n / 2; i++) {
			printf("? %d %d\n", (i - 1) * 2 + 1, i * 2);
			int c;
			cin >> c;
			if (c == 1) {
				v.insert(i * 2);
				v.insert(i * 2 - 1);
				cc++;
			}
		}
		
		if (n % 2 == 1) {
			printf("? %d %d\n", n - 1, n);
			int c;
			cin >> c;
			if (c == 1) {
				v.insert(n - 1);
				v.insert(n);
				cc++;
			}
		}
		
		if (cc == 0) {
			printf("! 1\n");
			fflush(stdout);	
			continue;
		}
		
		if (n % 2 == 1) {
			if (v.find(n - 2) != v.end() && v.find(n) != v.end()) {
				printf("? 1 %d\n", n - 1);	
				int c;
				cin >> c;
				if (c == 1) {
					printf("! 2\n");
					fflush(stdout);	
					continue;
				}
				
				else {
					printf("! 2\n");
					fflush(stdout);	
					continue;
				}
			}
		}
		
		if (cc > 1) {
			printf("! 1\n");
			fflush(stdout);	
			continue;
		}
		
		int a = -1, b = -1, e, f, g, h, j;
		for (auto it = v.begin(); it != v.end(); it++) {
			if (a == -1) a = *it;
			else b = *it;	
		}
		
		if (a == 1) e = n;
		else e = a - 1;
		if (b == n) f = 1;
		else f = b + 1;
		
		printf("? %d %d\n", a, e);
		cin >> g;
		printf("? %d %d\n", b, e);
		cin >> h;
		if (g == 1 && h == 1) {
			printf("! 1\n");	
			fflush(stdout);
			continue;
		}
		
		if (g == 1) {
			printf("? %d %d\n", a, f);
			cin >> j;
			if (j == 1) {
				printf("! 2\n");	
				fflush(stdout);
				continue;
			} else {
				printf("! 1\n");	
				fflush(stdout);
				continue;
			}	
		}
		
		if (h == 1) {
			printf("? %d %d\n", b, f);
			cin >> j;
			if (j == 1) {
				printf("! 2\n");	
				fflush(stdout);
				continue;
			} else {
				printf("! 1\n");	
				fflush(stdout);
				continue;
			}	
		}
		
		if (g == 0 && h == 0) {
			printf("! 1\n");	
			fflush(stdout);
			continue;
		}
	}
	
	return 0;	
}

詳細信息

Test #1:

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

input:

2
4
1
1
4
0
1
1
0
1

output:

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

result:

ok Correct (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3752kb

input:

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

output:

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

result:

wrong answer Wrong prediction (test case 70)