fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define int int64_t
  6.  
  7. unordered_map<int, int> used;
  8.  
  9. int win(int x) {
  10. if(used.count(x)) {
  11. return used[x];
  12. } else if(x == 0) {
  13. return false;
  14. } else if(x == 1) {
  15. return true;
  16. } else {
  17. if(x % 2 == 0) {
  18. return used[x] = !win(x / 2);
  19. } else {
  20. return used[x] = !win(x - 1) | !win(x + 1);
  21. }
  22. }
  23. }
  24.  
  25. void solve() {
  26. int n;
  27. cin >> n;
  28. if(!win(n)) {
  29. cout << "Lose" << endl;
  30. string t;
  31. cin >> t;
  32. } else {
  33. cout << "Win" << endl;
  34. while(n != 0) {
  35. if(n % 2 == 0) {
  36. cout << "/2" << endl;
  37. n /= 2;
  38. } else if(!win(n - 1)) {
  39. cout << "-1" << endl;
  40. n--;
  41. } else {
  42. cout << "+1" << endl;
  43. n++;
  44. }
  45. string t;
  46. cin >> t;
  47. if(t == "+1") {
  48. n++;
  49. } else if(t == "-1") {
  50. n--;
  51. } else if(t == "/2") {
  52. n /= 2;
  53. }
  54. }
  55. }
  56. }
  57.  
  58. signed main() {
  59. //freopen("input.txt", "r", stdin);
  60. ios::sync_with_stdio(0);
  61. cin.tie(0);
  62. int t;
  63. cin >> t;
  64. while(t--) {
  65. solve();
  66. }
  67. return 0;
  68. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
Standard output is empty