-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArray_queries.cpp
More file actions
43 lines (38 loc) · 877 Bytes
/
Array_queries.cpp
File metadata and controls
43 lines (38 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "bits/stdc++.h"
using namespace std;
void solve() {
int m;
cin >> m;
int q;
cin >> q;
vector<int> a;
int temp, tempai, xr = 0;
while (q--) {
cin >> temp;
if (temp == 1) {
cin >> tempai;
xr ^= tempai;
a.push_back(tempai);
} else if (temp == 2) {
xr ^= a[a.size() - 1];
a.pop_back();
} else {
// for (auto ele : a) cout << ele << " ";
int ans = 0, maxi = 0;
for (int i = 2 * m; i > 0; i--) {
if (ans < (xr ^ i)) {
ans = (xr ^ i);
maxi = i;
}
}
cout << maxi << endl;
}
}
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
cout.tie(0);
solve();
return 0;
}