fork(2) download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define scan(x) scanf("%d",&x)
  5. #define ll long long int
  6.  
  7. inline ll find_range_sum(ll L,ll R){
  8.  
  9. if(L>R)
  10. return 0;
  11. else{
  12. return ((R)*(R+1)-(L-1)*(L))/2;
  13. }
  14. }
  15. int main(){
  16. int t;
  17. scan(t);
  18. assert(t<=100000);
  19. while(t--){
  20. int n,k,i;
  21. scan(n); // size of permutation
  22. scan(k); // missing number
  23. assert(n<=1000000000&&n>=1);
  24. assert(k>=0&&k<=1000000);
  25. assert(k<=n);
  26. ll sum = find_range_sum(1,n);
  27. if(k){
  28. vector<int> arr(k); // all k given number are distinct
  29. set<int> S;
  30. for(int i=0;i<k;i++){
  31. scan(arr[i]);
  32. S.insert(arr[i]);
  33. }
  34. //assert(S.size()==k);
  35. sort(arr.begin(),arr.end()); // sort all the numbers
  36. sum=find_range_sum(1,arr[0]-1); // initial possible sum
  37. assert(arr[arr.size()-1] <= n);
  38. assert(arr[0] > 0) ;
  39. for(int i=1;i<k;i++){
  40. if(arr[i]-arr[i-1]==1)
  41. continue;
  42. if(sum+1>=(arr[i-1]+1)){
  43. sum+=find_range_sum(arr[i-1]+1,arr[i]-1); // finding the range of new possible sums.
  44. }else{
  45. // if sum not possible break
  46. break;
  47. }
  48. }
  49. if(sum+1 >= arr[k-1]+1) // if sum break out in between then even this sum is not possible because arr[k-1] > arr[x] where x < k-1. :P
  50. sum+=find_range_sum(arr[k-1]+1,n);
  51. //cout << sum << endl;
  52. }
  53. puts(sum%2?"Mom":"Chef");
  54. }
  55. return 0;
  56. }
Success #stdin #stdout 0s 3280KB
stdin
2
5 2
3 5
5 1
1
stdout
Mom
Chef