Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int k = 8;
- int m = 1 << k;
- int bm = m - 1;
- int[][] cnt = new int[m][m];
- int q = nextInt();
- while (--q >= 0) {
- char t = next().charAt(0);
- int s = nextInt();
- int x = s >> k; // first byte
- int y = s & bm; // second byte
- if (t == 'a') {
- for (int i = 0; i < m; i++) {
- if ((i & x) == x) {
- ++cnt[i][y];
- }
- }
- } else if (t == 'c') {
- int ans = 0;
- for (int i = 0; i < m; i++) {
- if ((i & y) == i) {
- ans += cnt[x][i];
- }
- }
- println(ans);
- } else if (t == 'd') {
- for (int i = 0; i < m; i++) {
- if ((i & x) == x) {
- --cnt[i][y];
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment