c++(217ms 72%) recursia
Runtime: 217 ms, faster than 72.22% of C++ online submissions for Stone Game IX.\nMemory Usage: 127.2 MB, less than 50.00% of C++ online submissions for Stone G
Runtime: 217 ms, faster than 72.22% of C++ online submissions for Stone Game IX.\nMemory Usage: 127.2 MB, less than 50.00% of C++ online submissions for Stone Game IX.\n```\nclass Solution {\npublic:\n  int helper(unsigned long s, unsigned long n0, unsigned long n1, unsigned long n2, int turn){\n    if(n0 == 0 && n1 == 0 && n2 == 0) return 1;\n    \n    int next_turn = 1^turn;\n    int tmp = next_turn;\n    \n    if(s == 0){\n      if(n1 || n2){\n        if(n1)                tmp = helper(1, n0, n1-1, n2, next_turn);\n        if(tmp != turn && n2) tmp = helper(2, n0, n1, n2-1, next_turn);\n      }\n    }\n    else if(s == 1){\n      if(n0 || n1){\n        if(n0)                tmp = helper(1, n0-1, n1, n2, next_turn);\n        if(tmp != turn && n1) tmp = helper(2, n0, n1-1, n2, next_turn);\n      }\n    }\n    else{\n      if(n0 || n2){\n        if(n0)                tmp = helper(2, n0-1, n1, n2, next_turn);\n        if(tmp != turn && n2) tmp = helper(1, n0, n1, n2-1, next_turn);\n      }\n    }\n    \n    return tmp;\n  }\n  \n  \n  bool stoneGameIX(vector<int>& stones) {\n    int n0 = 0, n1 = 0, n2 = 0;\n    \n    for(auto &x: stones){\n      int tmp = x % 3;\n      if(tmp == 0) n0++;\n      else if(tmp == 1) n1++;\n    }\n   \n    n2 = stones.size() - n0 - n1;\n    n0 = n0%2;                                      //without this small line we will have TLE and whan I wrote contest I don\'t consider it =(\n    return helper(0, n0, n1, n2, 0) == 0;\n  }\n};\n```
['C', 'C++']