fork(1) download
  1. #include<stdio.h>
  2. #include<iostream>
  3. #include<sstream>
  4. #include<queue>
  5. #include<math.h>
  6. #include<stdlib.h>
  7. #include<stack>
  8. #include<string.h>
  9. #include<string>
  10. #include<map>
  11. #include<algorithm>
  12. #include<time.h>
  13. #include<set>
  14. #include<vector>
  15. #include <numeric>
  16. using namespace std;
  17.  
  18. #define All(a) a.begin(), a.end()
  19. #define _2d(a,row,col,type) type**a=new type*[row]; for (int i=0;i<row;i++) a[i]=new type[col];
  20. #define rep(i,n) for(long i=0;i<long(n);i++)
  21. #define repd(i,n) for(int i=n-1;i>=0;i--)
  22. #define repi(i,a,n) for(int i=int(a);i<int(n);i++)
  23. #define scn(a,n) rep(i,n) cin>>a[i];
  24. #define scn2(a,row,col) rep(i,row) rep(j,col) cin>>a[i][j];
  25. #define prn(a,n) rep(i,n-1) cout<<a[i]<<" "; cout<<a[n-1]<<endl;
  26. #define prn2(a,row,col) rep(i,row){rep(j,col-1) cout<<a[i][j]<<" "; cout<<a[i][col-1]<<endl;}
  27. #define Odd(x) x%2!=0
  28. #define Even(x) x%2==0
  29. #define Pi 3.14
  30. #define INF 2000000000 // 2 billion
  31.  
  32. typedef vector<int> vi;
  33. typedef vector<long> vl;
  34. typedef vector<double> vd;
  35. typedef vector<string> vs;
  36. typedef pair<int, int> ii;
  37. typedef pair<int, string> is;
  38. typedef vector<ii> vii;
  39. typedef long long ll;
  40. typedef unsigned long ul;
  41. typedef unsigned long long ull;
  42. typedef long double ld;
  43.  
  44. using namespace std;
  45.  
  46. int main() {
  47.  
  48. long n,m;
  49. cin>>n;
  50. vector <ll> a(n,0),b(n,0);
  51. map<ll,long> ai,bi;
  52. ll temp = -1;
  53. rep(i,n) {
  54. cin>>a[i];
  55. if(a[i] > temp) {
  56. ai[a[i]] = i+1;
  57. temp = a[i];
  58. }
  59. }
  60. temp = -1;
  61. rep(i,n){
  62. cin>>b[i];
  63. if(b[i] > temp) {
  64. bi[b[i]] = i+1;
  65. temp = b[i];
  66. }
  67. }
  68. cin>>m;
  69. vector <ll> a1(m,0),b1(m,0);
  70. bool ok;
  71. rep(i,m){
  72. cin>>a1[i];
  73. }
  74. rep(i,m){
  75. cin>>b1[i];
  76. }
  77. long t1,t2;
  78. map<ll,long>::iterator i1,i2;
  79. rep(i,m){
  80.  
  81. // with upper bound
  82.  
  83. // i1 = ai.upper_bound(a1[i]);
  84. // i2 = bi.upper_bound(b1[i]);
  85.  
  86. //with lower bound
  87.  
  88.  
  89. i1 = ai.lower_bound(a1[i]);
  90. i2 = bi.lower_bound(b1[i]);
  91. ok = true;
  92. if(i1 == ai.end() && i2 == bi.end()) cout<<"Draw\n";
  93. else if (i1 == ai.end()) cout<<"Constantine\n";
  94. else if (i2 == bi.end()) cout<<"Mike\n";
  95. else if(i1->second < i2->second) cout<<"Mike\n";
  96. else if (i1->second > i2->second ) cout<<"Constantine\n";
  97. else{
  98.  
  99. cout<<"Draw\n";
  100. }
  101.  
  102. // it was my first checking
  103.  
  104. // for (;i1 != ai.end() && i2 != bi.end();){
  105. // if(i1->first <= a1[i] && i2->first <= b1[i] )
  106. // {
  107. // if(i1->second < i2->second) i1++;
  108. // else if (i1->second > i2->second) i2++;
  109. // else i1++, i2++;
  110. // }
  111. // else if(i1->first <= a1[i] && i2->first > b1[i] ){
  112. // cout<<"Constantine\n";
  113. // ok=0;
  114. // break;
  115. // }
  116. // else if(i1->first > a1[i] && i2->first <= b1[i] ){
  117. // cout<<"Mike\n";
  118. // ok=0;
  119. // break;
  120. // }
  121. // else {
  122. // if(i1->second < i2->second){
  123. // cout<<"Mike\n";
  124. // ok = false;
  125. // break;
  126. // }
  127. // else if(i1->second > i2->second){
  128. // cout<<"Constantine\n";
  129. // ok = false;
  130. // break;
  131. // }
  132. // else{
  133. // cout<<"Draw\n";
  134. // ok = false;
  135. // break;
  136. // }
  137. // }
  138. // }
  139. // if(ok){
  140. // if(i1 == ai.end()){
  141. // for(;i2 != bi.end();){
  142. // if(i2->first > b1[i])
  143. // {
  144. // cout<<"Constantine\n";
  145. // ok = false;
  146. // break;
  147. // }
  148. // i2++;
  149. // }
  150. // if(ok) cout<<"Draw\n";
  151. // }
  152. // else{
  153. // for(;i1 != ai.end();){
  154. // if(i1->first > a1[i])
  155. // {
  156. // cout<<"Mike\n";
  157. // ok = false;
  158. // break;
  159. // }
  160. // i1++;
  161. // }
  162. // if(ok) cout<<"Draw\n";
  163. // }
  164. // }
  165. }
  166. return 0;
  167. }
  168.  
Runtime error #stdin #stdout #stderr 0s 3476KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc