QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#371265#7804. Intersegment ActivationFOY#WA 1ms3796kbC++23889b2024-03-30 03:40:042024-03-30 03:40:05

Judging History

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

  • [2024-03-30 03:40:05]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3796kb
  • [2024-03-30 03:40:04]
  • 提交

answer

#include <iostream>
#include <vector>
#include <bitset>
#include <cassert>
using namespace std;

vector<int> gray(int n) {
	vector<int> gray = {0};
	for (int i = 1; i < n; i++) {
		gray.push_back(i);
		for (int j = gray.size()-2; j >= 0; j--) gray.push_back(gray[j]);
	}
	gray.push_back(n-1);
	return gray;
}
int main() {
	int n; cin >> n;

	for (int i = 0; i < n; i++) {
		int best = 0, bestMask = 0;
		int mask = 0;
		auto g = gray(n-i);
		for (int j = 0; j < (1<<(n-i)); j++) { 
			cout << i+1 << ' ' << i+1+g[j] << endl;
			mask ^= (1<<g[j]);
			int val; cin >> val;
			if (val == n) return 0;
			if (val > best) {
				best = val;
				bestMask = mask;
			}
		}
		assert(mask == 0);
		int val;
		while (bestMask) {
			cout << i+1 << ' ' << i+__builtin_ctz(bestMask)+1 << endl;
			bestMask -= bestMask&-bestMask;
			int val; cin >> val;
		}
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
0
0
0
1
0
0
0
0
0
1
0
0
0
0
0
0
0

output:

1 1
1 2
1 1
1 3
1 1
1 2
1 1
1 3
1 2
1 3
2 2
2 3
2 2
2 3
3 3
3 3

result:

wrong answer format  Unexpected end of file - int32 expected