Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- bitset<4096> octree;
- string s;
- int processBitset(int i, int start, int end, bitset<4096> &o) {
- if(start == end) {
- if(s[i] == 'b'){
- o.set(start);
- }
- return i + 1;
- } else {
- if(s[i] == 'p') {
- int cur = i + 1;
- int size = end - start + 1;
- int chop = size / 8;
- for(int j = 0; j < 8; j++) {
- cur = processBitset(cur,start + chop * j,start + chop * (j + 1) - 1,o);
- }
- return cur;
- } else {
- if(s[i] == 'b') {
- for(int j = start; j <= end; j++) {
- o.set(j);
- }
- }
- return i + 1;
- }
- }
- }
- int main() {
- int nCtr;
- scanf("%d",&nCtr);
- for(int x = 0; x < nCtr; x++) {
- octree.reset();
- cin >> s;
- processBitset(0,0,4095,octree);
- cin >> s;
- processBitset(0,0,4095,octree);
- printf("%d\n",octree.count());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement