QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#371269#7804. Intersegment ActivationFOY#RE 0ms0kbC++23905b2024-03-30 03:53:312024-03-30 03:53:31

Judging History

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

  • [2024-03-30 03:53:31]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-03-30 03:53:31]
  • 提交

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;

	int val;
	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 < g.size(); j++) { 
			cout << i+1 << ' ' << i+1+g[j] << endl;
			mask ^= (1<<g[j]);
			cin >> val;
			if (val == n) return 0;
			if (val > best) {
				best = val;
				bestMask = mask;
			}
		}
		assert(mask == 0);
		while (bestMask) {
			cout << i+1 << ' ' << i+__builtin_ctz(bestMask)+1 << endl;
			bestMask -= 1<<__builtin_ctz(bestMask);
			int val; cin >> val;
		}
	}
	assert(val == n);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

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: