QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#333608#8239. Mysterious TreeDualqwq#WA 1ms3792kbC++17924b2024-02-20 10:00:202024-02-20 10:00:20

Judging History

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

  • [2024-02-20 10:00:20]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3792kb
  • [2024-02-20 10:00:20]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
int n;
inline int Ask(int x,int y) {
	printf("? %d %d\n",x,y);
	fflush(stdout);
	int res;cin >> res;return res;
}
inline void work() {
	cin >> n;
	for(int i = 1;i <= n / 2;i += 2) {
		int v = Ask(i,i + 1);
		if(v) {
			int x = i,y = i + 1;
			int v1 = 0,v2 = 0;
			for(int j = 1;j <= n;j++)
				if(j != x && j != y) {
					if(!v1) v1 = j; else v2 = j;
				}
			int r1 = Ask(x,v1),r2 = Ask(y,v1);
			if(!r1 && !r2) 
				{cout << "! 1" << endl;fflush(stdout);return;}
			if(!r1) swap(x,y);
			if(!Ask(v2,x)) { cout << "! 1" << endl;fflush(stdout);return;}
			cout << "! 2" << endl;fflush(stdout);return;
		}
	}
	int cnt = 0;
	for(int i = 1;i <= 3;i++) cnt += Ask(i,n);
	if(cnt == 3) cout << "! 2" << endl;
	else cout << "! 1" << endl;
	fflush(stdout);
}
int main() {
	int T;
	cin >> T;
	while(T--) work();
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3792kb

input:

2
4
1
0
1
0
4
0
0
0
1

output:

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

result:

wrong answer Wrong prediction (test case 2)