-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodechef - chef and happiness.cpp
69 lines (61 loc) · 1.31 KB
/
codechef - chef and happiness.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include<bits/stdc++.h>
using namespace std;
const int sz = 100101;
int arr[sz];
pair<int, int> data[sz];
bool ans;
int cnt;
int i, j;
int t, n, ai;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> t;
while(t--)
{
cin >> n;
for(i=1; i<=n; i++)
{
cin >> ai;
arr[i] = ai;
data[i] = make_pair(ai, i);
}
sort(arr+1, arr+n+1);
sort(data+1, data+n+1);
ans = false;
for(i=1; i<n; i++)
{
if(data[i].first==data[i+1].first)
{
if(!binary_search(arr+1, arr+n+1, data[i].second))
{
continue;
}
for(j=i+1; data[i].first==data[j].first && j<=n; j++)
{
if(binary_search(arr+1, arr+n+1, data[j].second))
{
ans = true;
break;
}
}
if(ans)
{
break;
}
i=j-1;
}
}
if(ans)
{
cout << "Truly Happy";
}
else
{
cout << "Poor Chef";
}
cout << "\n";
}
return 0;
}