fork download
  1. /*....tanay chakraborty......*/
  2.  
  3. #include<bits/stdc++.h>
  4. using namespace std;
  5.  
  6. typedef long long ll;
  7. typedef vector<int> vi;
  8. typedef vector<ll> vl;
  9. typedef vector<vi> vvi;
  10. typedef vector<vl> vvl;
  11. typedef pair<int,int> pii;
  12. typedef pair<double, double> pdd;
  13. typedef pair<ll, ll> pll;
  14. typedef vector<pii> vii;
  15. typedef vector<pll> vll;
  16. typedef double dl;
  17.  
  18. #define PB push_back
  19. #define F first
  20. #define S second
  21. #define MP make_pair
  22. #define endl '\n'
  23. #define all(a) (a).begin(),(a).end()
  24. #define sz(x) (int)x.size()
  25. #define mid(l,r) ((r+l)/2)
  26. #define left(node) (node*2)
  27. #define right(node) (node*2+1)
  28. #define mx_int_prime 999999937
  29.  
  30. const double PI = acos(-1);
  31. const double eps = 1e-9;
  32. const int inf = 2000000000;
  33. const ll infLL = 9000000000000000000;
  34. #define MOD 1000000007
  35.  
  36. #define mem(a,b) memset(a, b, sizeof(a) )
  37. #define gcd(a,b) __gcd(a,b)
  38. #define sqr(a) ((a) * (a))
  39.  
  40. #define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  41. #define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
  42. #define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
  43.  
  44. typedef vector<int>::iterator vit;
  45. typedef set<int>::iterator sit;
  46.  
  47.  
  48. int dx[] = {0, 0, +1, -1};
  49. int dy[] = {+1, -1, 0, 0};
  50. //int dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};
  51. //int dy[] = {0, +1, 0, -1, +1, -1, +1, -1};
  52.  
  53.  
  54.  
  55. template < typename F, typename S >
  56. ostream& operator << ( ostream& os, const pair< F, S > & p ) {
  57. return os << "(" << p.first << ", " << p.second << ")";
  58. }
  59.  
  60. template < typename T >
  61. ostream &operator << ( ostream & os, const vector< T > &v ) {
  62. os << "{";
  63. for(auto it = v.begin(); it != v.end(); ++it) {
  64. if( it != v.begin() ) os << ", ";
  65. os << *it;
  66. }
  67. return os << "}";
  68. }
  69.  
  70. template < typename T >
  71. ostream &operator << ( ostream & os, const set< T > &v ) {
  72. os << "[";
  73. for(auto it = v.begin(); it != v.end(); ++it) {
  74. if( it != v.begin() ) os << ", ";
  75. os << *it;
  76. }
  77. return os << "]";
  78. }
  79.  
  80. template < typename T >
  81. ostream &operator << ( ostream & os, const multiset< T > &v ) {
  82. os << "[";
  83. for(auto it = v.begin(); it != v.end(); ++it) {
  84. if( it != v.begin() ) os << ", ";
  85. os << *it;
  86. }
  87. return os << "]";
  88. }
  89.  
  90. template < typename F, typename S >
  91. ostream &operator << ( ostream & os, const map< F, S > &v ) {
  92. os << "[";
  93. for(auto it = v.begin(); it != v.end(); ++it) {
  94. if( it != v.begin() ) os << ", ";
  95. os << it -> first << " = " << it -> second ;
  96. }
  97. return os << "]";
  98. }
  99.  
  100. #define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
  101.  
  102. void faltu () {
  103. cerr << endl;
  104. }
  105.  
  106. template <typename T>
  107. void faltu( T a[], int n ) {
  108. for(int i = 0; i < n; ++i) cerr << a[i] << ' ';
  109. cerr << endl;
  110. }
  111.  
  112. template <typename T, typename ... hello>
  113. void faltu( T arg, const hello &... rest) {
  114. cerr << arg << ' ';
  115. faltu(rest...);
  116. }
  117.  
  118.  
  119. int main()
  120. {
  121. optimize();
  122. ll tc; cin >> tc;
  123. while(tc--){
  124. ll n; cin >> n;
  125. vl a(n),b(n);
  126. for(auto &u : a) cin >> u;
  127. for(auto &u : b) cin >> u;
  128.  
  129. ll c1=0,c2=0;
  130. // for(int i=0; i<n; i++){
  131. // if(a[i]!=b[i]){
  132. // if(!(i&1)) odd_ans++;
  133. // else even_ans++;
  134. // }
  135. // }
  136.  
  137. // 0 --> Aji 1-->mai
  138.  
  139. // for(int i=0;i<n;i++){
  140. // if(a[i]==1 && b[i]==1) {
  141. // c1++;
  142. // c2++;}
  143. // if(a[i]==0 && b[i]==0) continue;
  144. // if(i%2==0 && a[i]!=b[i]){
  145. // if(c1%2!=0) c2++;
  146. // else c1++;
  147. // }
  148. // else if(i%2!=0 && a[i]!=b[i]) {
  149. // if(c2%2!=0) c1++;
  150. // else c2++;
  151. // }
  152.  
  153. for(int i=0;i<n;i++) if(a[i]==1 && b[i]==1){
  154. c1++;
  155. c2++;
  156. }
  157.  
  158. for(int i=0;i<n;i++){
  159. if(a[i]==b[i]) continue;
  160. if(i%2==0){
  161. if(c1%2!=0) c2++;
  162. else c1++;
  163. }
  164. else{
  165. if(c2%2!=0) c1++;
  166. else c2++;
  167. }
  168. }
  169.  
  170. if((c1%2!=0) == (c2%2!=0)) cout <<"Tie" << endl;
  171. else if(c1%2!=0) cout << "Ajisai" << endl;
  172. else cout << "Mai"<< endl;
  173.  
  174. }
  175.  
  176.  
  177. }
  178.  
Success #stdin #stdout 0.01s 5268KB
stdin
1
5
1 0 1 1 0
0 1 0 1 1
stdout
Tie