Advertisement
Guest User

Untitled

a guest
Jun 26th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. // In the name of GOD
  2. #include <iostream>
  3. #include <algorithm>
  4. #include <fstream>
  5. #include <vector>
  6. #include <deque>
  7. #include <assert.h>
  8. #include <queue>
  9. #include <stack>
  10. #include <set>
  11. #include <map>
  12. #include <tuple>
  13. #include <stdio.h>
  14. #include <string.h>
  15. #include <utility>
  16. #include <math.h>
  17. using namespace std;
  18. inline int in(){int32_t x ; scanf("%d",&x) ; return x ; }
  19. inline string get(){char ch[1000010] ; scanf("%s",ch) ; return ch;}
  20. const int MAX_LG = 21;
  21. //#define int long long
  22. #define endl "\n"
  23. #define mp make_pair
  24. typedef pair<int , int > pii;
  25. typedef long double ld;
  26. typedef unsigned long long ull;
  27. typedef long long ll;
  28. const int maxn = 3e3 + 10;
  29. const int INF = 1e9;
  30. const int SQ = 317;
  31. const int mod = 10499;
  32. bool have[maxn];
  33. class Roxor
  34. {
  35. public:
  36. map<int,bool> Map;
  37. bool win(int mask , int n)
  38. {
  39. if (Map.count(mask)) return Map[mask];
  40. bool res = false;
  41. for (int i = 0 ; i < n - 1 ; i ++)
  42. {
  43. if ((mask & (1 << i) )== 0 ) continue;
  44. for (int j = i + 1 ; j < n ; j ++)
  45. {
  46. for (int k = j ; k < n ; k ++)
  47. {
  48. res |= !win(mask ^ (1 << i) ^ (1 << j) ^ (1 << k) , n);
  49. }
  50. }
  51. }
  52. return Map[mask] = res;
  53. }
  54. vector <int> play(vector <int> piles)
  55. {
  56. int n = (int)piles.size();
  57. for (int i = 0 ; i < n ; i ++)have[i] = bool(piles[i]) , piles[i] %= 2;
  58. int mask = 0;
  59. for (int i = 0 ; i < n ; i ++)
  60. mask += (1 << i)*piles[i];
  61. vector<int> res = {};
  62. for (int i = 0 ; i < n - 1 ; i ++)
  63. {
  64. if (have[i])
  65. for (int j = i + 1 ; j < n ; j ++)
  66. {
  67. for (int k = j ; k < n ; k ++)
  68. {
  69. if (!win(mask ^ (1 << i) ^ (1 << j) ^ (1 << k) , n ))
  70. {
  71. res.push_back(i);
  72. res.push_back(j);
  73. res.push_back(k);
  74. return res;
  75. }
  76. }
  77. }
  78. }
  79. return res;
  80. }
  81. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement