fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. //#pragma GCC optimize("03,unroll-loops")
  6. //#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
  7.  
  8. #define Morshedy_22 ios_base::sync_with_stdio(false);cin.tie(nullptr);
  9. #define F first
  10. #define S second
  11. #define pb push_back
  12. #define all(v) v.begin(),v.end()
  13. #define rall(v) v.rbegin(),v.rend()
  14. #define FILL(a, b) memset(a, b, sizeof(a))
  15. #define popCnt(x) (__builtin_popcountll(x))
  16. #define sz(x) (int)(x).size()
  17. #define el '\n'
  18. #define int ll
  19.  
  20. typedef long long ll;
  21. typedef pair<int, int> pii;
  22. typedef pair<pii, int> piii;
  23. typedef vector<int> vi;
  24. typedef vector<vi> vvi;
  25. typedef vector<pii> vii;
  26.  
  27. const int inf = 0x3f3f3f3f;
  28. const ll infLL = 0x3f3f3f3f3f3f3f3fLL;
  29. const int N = 1e5+5;
  30. const int mod = 1e9+7;
  31. const int d4x[4]={-1, 0, 1, 0}, d4y[4]={0, 1, 0, -1};
  32. const int d8x[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8y[8]={0, 1, 1, 1, 0, -1, -1, -1};
  33.  
  34. void dbg_out() { cerr << endl; }
  35. template <typename Head, typename... Tail>
  36. void dbg_out(Head H, Tail... T) {
  37. cerr << ' ' << H;
  38. dbg_out(T...);
  39. }
  40. #define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
  41.  
  42. /*
  43. ---> وتظل تسعى جاهدا في همةٍ .. والله يعطي من يشاءُ إذا شكر <---
  44. */
  45.  
  46. int grid[3][3], game[3][3];
  47.  
  48. int check(int c)
  49. {
  50. // check rows
  51. if(game[0][0] == game[0][1] and game[0][1] == game[0][2] and game[0][2] == c)
  52. return 1;
  53. if(game[1][0] == game[1][1] and game[1][1] == game[1][2] and game[1][2] == c)
  54. return 1;
  55. if(game[2][0] == game[2][1] and game[2][1] == game[2][2] and game[2][2] == c)
  56. return 1;
  57.  
  58. // check columns
  59. if(game[0][0] == game[1][0] and game[1][0] == game[2][0] and game[2][0] == c)
  60. return 1;
  61. if(game[0][1] == game[1][1] and game[1][1] == game[2][1] and game[2][1] == c)
  62. return 1;
  63. if(game[0][2] == game[1][2] and game[1][2] == game[2][2] and game[2][2] == c)
  64. return 1;
  65.  
  66. // check diagonals
  67. if(game[0][0] == game[1][1] and game[1][1] == game[2][2] and game[2][2] == c)
  68. return 1;
  69. if(game[0][2] == game[1][1] and game[1][1] == game[2][0] and game[2][0] == c)
  70. return 1;
  71.  
  72. return -1;
  73. }
  74.  
  75.  
  76. // who (0 = takahashi, 1 = Aoki)
  77. int solve(int who, int sum1, int sum2, int cnt)
  78. {
  79. // int ch = check(who^1);
  80. // if(ch)
  81. // return 1;
  82.  
  83. // draw
  84. if(cnt == 9)
  85. return sum1 > sum2;
  86.  
  87. int ret = -1;
  88. for(int i=0; i<3; i++)
  89. {
  90. for(int j=0; j<3; j++)
  91. {
  92.  
  93. if(game[i][j] == -1)
  94. {
  95. game[i][j] = who;
  96.  
  97. if(who == 0)
  98. {
  99. ret = solve(who^1, sum1+grid[i][j], sum2, cnt+1);
  100.  
  101. }
  102. else if(who == 1)
  103. {
  104. ret = solve(who^1, sum1, sum2+grid[i][j], cnt+1);
  105.  
  106. }
  107.  
  108. game[i][j] = -1;
  109. }
  110. }
  111. }
  112. if(who = 1)
  113. {
  114. if(ret == 1) return 1;
  115. else return 0;
  116. }
  117.  
  118. else { if(ret == 0) return 1;
  119. return 0;}
  120.  
  121. return check(who);
  122. }
  123.  
  124. void testCase()
  125. {
  126. for(int i=0; i<3; i++)
  127. for(int j=0; j<3; j++)
  128. cin >> grid[i][j];
  129.  
  130. FILL(game, -1);
  131. cout << (solve(0, 0, 0, 0) ? "Takahashi" : "Aoki");
  132. }
  133.  
  134.  
  135. int32_t main()
  136. {
  137. Morshedy_22
  138.  
  139. int tc = 1;
  140. // cin >> tc;
  141. while(tc--)
  142. testCase();
  143.  
  144.  
  145. return 0;
  146. }
  147.  
Success #stdin #stdout 0.02s 5304KB
stdin
对象 QQApiAudioObject* audioObj = [QQApiAudioObject objectWithURL:[NSURL URLWithString:utf8String ? : @“”] title:self.binding_title ? : @“” description:self.binding_description ? : @“” previewImageData: eh h
stdout
Aoki