Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void process(vuc init, pair<int, int>* ans1, pair<int, int>* ans2, int num_bit, unordered_map<int, pair<int, int>>* st, bool flag) {
- int i = 0, temp;
- while(true) {
- mtx.lock();
- if (*ans1 != pair<int, int>() && *ans2 != pair<int, int>()) {
- mtx.unlock();
- return;
- }
- mtx.unlock();
- temp = shaxx(init, num_bit);
- if ((temp & ((1 << (num_bit >> 1)) - 1)) == 0) {
- mtx.lock();
- if ((*st).count(temp)) {
- *ans1 = {i, flag};
- *ans2 = (*st)[temp];
- return;
- }
- (*st)[temp] = {i, flag};
- mtx.unlock();
- }
- init = pad(temp);
- i++;
- }
- }
- void task2() {
- auto i = new pair<int, int>();
- auto j = new pair<int, int>();
- auto st = new unordered_map<int, pair<int, int>>();
- thread th1(process, first, i, j, MINNUMBIT, st, 0);
- thread th2(process, second, i, j, MINNUMBIT, st, 1);
- th1.join();
- th2.join();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement