fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define out(a) copy(a.begin(),a.end(),ostream_iterator<int>(cout," "))
  5. bool vist[501][501][501];
  6.  
  7. class BearPlaysDiv2 {
  8. public:
  9. string equalPiles(int A, int B, int C) {
  10. queue<int> que;
  11. int arr[] = { A, B, C }, tmp[3];
  12. sort(arr, arr + 3);
  13. for (int i = 0; i < 3; ++i)
  14. que.push(arr[i]);
  15. vist[arr[0]][arr[1]][arr[2]] = 1;
  16. while (que.size()) {
  17. for (int i = 0; i < 3; ++i) {
  18. arr[i] = que.front();
  19. que.pop();
  20. }
  21. if (arr[0] == arr[1] && arr[0] == arr[2])
  22. return "possible";
  23. for (int i = 1; i < 3; ++i) {
  24. memcpy(tmp, arr, sizeof tmp);
  25. tmp[i] -= tmp[i - 1];
  26. tmp[i - 1] *= 2;
  27. sort(tmp, tmp + 3);
  28. if (vist[tmp[0]][tmp[1]][tmp[2]])
  29. continue;
  30. vist[tmp[0]][tmp[1]][tmp[2]] = 1;
  31. for (int i = 0; i < 3; ++i)
  32. que.push(tmp[i]);
  33. }
  34. memcpy(tmp, arr, sizeof tmp);
  35. tmp[2] -= tmp[0];
  36. tmp[0] *= 2;
  37. sort(tmp, tmp + 3);
  38. if (vist[tmp[0]][tmp[1]][tmp[2]])
  39. continue;
  40. vist[tmp[0]][tmp[1]][tmp[2]] = 1;
  41. for (int i = 0; i < 3; ++i)
  42. que.push(tmp[i]);
  43. }
  44. return "impossible";
  45. }
  46. };
  47.  
  48.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/lib/gcc/i586-linux-gnu/5/../../../i386-linux-gnu/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty