Created
August 15, 2016 10:03
-
-
Save dyatlov/203d1047ff2a35c138e7c696c369a1b9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cmath> | |
#include <cstdio> | |
#include <vector> | |
#include <iostream> | |
#include <algorithm> | |
#include <bitset> | |
using namespace std; | |
int main() { | |
int n, m, i, j, op, x, oc=0, v, res; | |
string s; | |
cin >> n; | |
cin >> m; | |
vector< vector<int> > stack(m, vector<int>(3)); | |
for(i=0; i<m; i++){ | |
cin >> op; | |
if (op==1 || op==2){ | |
cin >> x; | |
cin >> s; | |
stack[oc][0] = op; | |
stack[oc][1] = x; | |
stack[oc][2] = bitset<32>(s).to_ulong(); | |
oc++; | |
} else { | |
cin >> s; | |
v = bitset<32>(s).to_ulong(); | |
res = 0; | |
for (j=oc-1; j>=0; j--){ | |
//cout << "test: " << v << "\t" << stack[j][2] << " = " << (v & stack[j][2]) << endl; | |
if ((stack[j][2] & v) == v){ | |
//cout << "matches: " << v << "\t" << stack[j][2] << endl; | |
if (stack[j][0]==1){ | |
cout << (res ^ stack[j][1]) << endl; | |
break; | |
} else { | |
res ^= stack[j][1]; | |
} | |
} | |
} | |
if (j<0) | |
cout << res << endl; | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment