fork download
  1. #include<iostream>
  2. #include<algorithm>
  3. using namespace std;
  4.  
  5. typedef long long int ll;
  6. ll t,n,a[100005],b[100005];
  7.  
  8. struct st
  9. {
  10. ll ind;
  11. ll val;
  12. bool valid;
  13. };
  14.  
  15. st str[100005];
  16.  
  17. bool compare(st a,st b)
  18. {
  19. return a.val<b.val;
  20. }
  21.  
  22. bool result()
  23. {
  24. for(int i=0;i<n;i++)
  25. {
  26. if(!str[i].valid)
  27. continue;
  28. ll j=i+1;
  29. while(str[i].val==str[j].val)
  30. {
  31. if(str[j].valid)
  32. return true;
  33.  
  34. j++;
  35. if(j==n)
  36. break;
  37. }
  38. }
  39. return false;
  40. }
  41.  
  42. int main()
  43. {
  44. cin>>t;
  45. while(t--)
  46. {
  47. cin>>n;
  48. for(int i=0;i<n;i++)
  49. {
  50. cin>>a[i];
  51. b[i]=a[i];
  52. str[i].ind=i+1;
  53. str[i].val=a[i];
  54. }
  55.  
  56. sort(b,b+n);
  57.  
  58. for(int i=0;i<n;i++)
  59. {
  60. if(binary_search(b,b+n,str[i].ind))
  61. str[i].valid=true;
  62. else
  63. str[i].valid=false;
  64. }
  65. sort(str,str+n,compare);
  66.  
  67. if(result())
  68. cout<<"Truly Happy"<<endl;
  69. else
  70. cout<<"Poor Chef"<<endl;
  71. }
  72. }
  73.  
Success #stdin #stdout 0s 19144KB
stdin
Standard input is empty
stdout
Standard output is empty