QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#487302#7804. Intersegment ActivationzhangbojuWA 1ms3844kbC++17884b2024-07-22 19:59:292024-07-22 19:59:29

Judging History

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

  • [2024-07-22 19:59:29]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3844kb
  • [2024-07-22 19:59:29]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
vector<int> get(int n) {
	vector<int> ans = {0};
	for (int i = 1; i < n; i++) {
		ans.push_back(i);
		vector<int> res = ans;
		res.pop_back();
		reverse(res.begin(), res.end());
		for (int x : res) ans.push_back(x);
	}
	ans.push_back(n - 1);
	return ans;
}
int query(int x, int len) {
	cout << x + 1 << " " << x + len + 1 << endl;
	int val;
	cin >> val;
	return val;
}
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int maxx = 0, maxS = 0;
		int S = 0;
		vector<int> v = get(n - i);
		for (int x : v) {
			int val = query(i, x);
			S ^= (1 << x);
			if (val == n) {
				return 0;
			}
			if (val > maxx) {
				maxx = val;
				maxS = S;
			}
		}
		while (maxS) {
			int x = query(i, __builtin_ctz(maxS));
			if (x == n) return 0;
			maxS -= (1 << __builtin_ctz(maxS));
		}
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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