Untitled
unknown
plain_text
a year ago
1.0 kB
13
Indexable
int encode() { result.clear(); s = stack<block>();//contain block int r1 = 0, r2 = n - 1; int c1 = 0, c2 = n - 1; toado top = { r1,c1 }; toado bot = { r2,c2 }; block bigest = { top,bot }; s.push(bigest); result.push_back('('); // while (!s.empty()) { block currentBlock = s.top(); s.pop(); r1 = currentBlock.top.x; c1 = currentBlock.top.y; r2 = currentBlock.bot.x; c2 = currentBlock.bot.y; // bool nigga = check(r1,c1,r2,c2); // if (nigga) { result.push_back(map[r1][c1]); } else { //xet 2x2 if (r2 == r1 + 1 && c2 == c1 + 1) { result.push_back('('); result.push_back(map[r1][c1] + '0'); result.push_back(map[r1][c2] + '0'); result.push_back(map[r2][c1] + '0'); result.push_back(map[r2][c2] + '0'); result.push_back(')'); } else { //chia binh thuong result.push_back('('); } } } // result.push_back(')'); return result.size() + pow(n, 2) / 16 + 2; }
Editor is loading...
Leave a Comment