QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#417670#8719. 后继fallleaves01#WA 1ms3744kbC++201.2kb2024-05-22 20:36:292024-05-22 20:36:31

Judging History

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

  • [2024-05-22 20:36:31]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3744kb
  • [2024-05-22 20:36:29]
  • 提交

answer

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	int n, m;
	cin >> n >> m;
	vector<int> a(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < m; i++) {
		int x = 0;
		vector<pair<int, int>> p = {pair{1, n}};
		for (int i = 29; i >= 0; i--) {
			pair<int, int> dv = {-1, -1};
			for (auto [l, r] : p) {
				if ((a[l] ^ a[r]) & (1 << i)) {
					dv = {l, r};
				}
			}
			if (dv.first == -1) {
				continue;
			}
			for (int j = dv.first; j < dv.second; j++) {
				if (a[j + 1] & (1 << i)) {
					cout << "? " << j + 1 << endl;
					int res;
					cin >> res;
					if (res >= dv.first && res <= j) {
						x ^= 1 << i;
					}
					break;
				}
			}
			auto tmp = p;
			p.clear();
			for (auto [l, r] : tmp) {
				int d = -1;
				for (int j = l; j < r; j++) {
					if (a[j + 1] & (1 << i)) {
						d = j;
						break;
					}
				}
				if (d != -1) {
					p.emplace_back(l, d);
					p.emplace_back(d + 1, r);
				} else {
					p.emplace_back(l, r);
				}
			}
		}
		cout << "! " << x << endl;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3492kb

input:

5 1
1 2 3 4 5
-1
1
4

output:

? 4
? 2
? 5
! 3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 1ms
memory: 3456kb

input:

1 1
0

output:

! 0

result:

ok 1 number(s): "0"

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3744kb

input:

10 10
380864879 387438357 21484978 21099484 375657510 23189485 24467021 379687119 386094773 15156199
9
1
2
4
7
6
3
9
7
5
4
-1
6
3
9
1
3
10
-1
6
7
9
2
5
-1
3
6
7
9
-1
5
4
2
6
3
9
-1
5
4
2
6
3
8
4
1
7
-1
10
3
9
2
5
-1
3
6
7
10
8
1
7
3
-1
6
-1
9
1
7
6
4
3

output:

? 2
? 5
? 8
? 6
? 10
? 7
? 4
! 1056768
? 2
? 5
? 8
? 6
? 10
? 7
? 4
! 34611200
? 2
? 5
? 8
? 6
? 10
? 7
? 4
! 1048576
? 2
? 5
? 8
? 6
? 10
? 7
? 4
! 101711872
? 2
? 5
? 8
? 6
? 10
? 7
? 4
! 34611200
? 2
? 5
? 8
? 6
? 10
? 7
? 4
! 34611200
? 2
? 5
? 8
? 6
? 10
? 7
? 4
! 67117056
? 2
? 5
? 8
? 6
? 10
...

result:

wrong answer 1st numbers differ - expected: '271581184', found: '1056768'