Advertisement
limimage

VLADIMIR_I_NEED_HELP

Mar 18th, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. void process(vuc init, pair<int, int>* ans1, pair<int, int>* ans2, int num_bit, unordered_map<int, pair<int, int>>* st, bool flag) {
  2. int i = 0, temp;
  3. while(true) {
  4. mtx.lock();
  5. if (*ans1 != pair<int, int>() && *ans2 != pair<int, int>()) {
  6. mtx.unlock();
  7. return;
  8. }
  9. mtx.unlock();
  10. temp = shaxx(init, num_bit);
  11. if ((temp & ((1 << (num_bit >> 1)) - 1)) == 0) {
  12. mtx.lock();
  13. if ((*st).count(temp)) {
  14. *ans1 = {i, flag};
  15. *ans2 = (*st)[temp];
  16. return;
  17. }
  18. (*st)[temp] = {i, flag};
  19. mtx.unlock();
  20. }
  21. init = pad(temp);
  22. i++;
  23. }
  24. }
  25.  
  26. void task2() {
  27. auto i = new pair<int, int>();
  28. auto j = new pair<int, int>();
  29. auto st = new unordered_map<int, pair<int, int>>();
  30.  
  31. thread th1(process, first, i, j, MINNUMBIT, st, 0);
  32. thread th2(process, second, i, j, MINNUMBIT, st, 1);
  33. th1.join();
  34. th2.join();
  35.  
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement