#include
using namespace std;
int main()
{
int t,x,y,k,n,i;
cin>>t;
while(t–)
{
cin>>x>>y>>k>>n;
int b[n][2],f=0;
for(i=0;i<n;i++)
cin>>b[i][0]>>b[i][1];
for(i=0;i<n;i++)
if((b[i][0]>=(x-y))&&(b[i][1]<=k))
{
f=1;
break;
}
if(f==1)
cout<<“LuckyChef”<<endl;
else
cout<<“UnLuckyChef”<<endl;
}
return 0;
}
You are printing UnLuckyChef
instead of UnluckyChef
The ‘L’ must be in lowercase!
There are couple of things :
1. The ‘L’ must be in lowercase! (i.e. print UnluckyChef instead of UnLuckyChef)
2. Your code prints the result after every input. Dont do that print all the results at the end. Pls check “Sample input” & “Sample Output” given. Check with the following input :
2
3 1 2 2
3 4
2 2
3 1 2 2
2 3
2 3
Expected Output :
LuckyChef
UnluckyChef
Output from your program :
2
3 1 2 2
3 4
2 2
Luckychef
3 1 2 2
2 3
2 3
UnluckyChef
3. Then there is a logical error. Check with the following input :
1
3 1 2 4
2 5
2 5
2 5
2 5
Expected Output :
Unluckychef
Output from your program :
Unluckychef
Unluckychef
Unluckychef
Unluckychef
(Fix this. It should print only once not 4 times. Its a logical error !)
Hope this helps !