 # CNOTE - Editorial

Now I get it. Thanks !

Here’s a more pythonic code golf:

``````for _ in xrange(input()):
X, Y, K, N = map(int, raw_input().split())
print ["UnluckyChef", "LuckyChef"][any(P >= X - Y and C <= K for P, C in [map(int, raw_input().strip().split()) for i in xrange(N)])]``````
2 Likes

When you post code, you should try indenting all your code four spaces, so that it renders properly as code.

because you are breaking the loop after getting result. you are not collecting all the input data. hence getting the wrong answer. remove break statement and you would get the correct answer.

i get a wrong answer when i use this snippet to take an integer input
int fastscan()
{
int c = gc();
int x = 0;
for (; (c>47 && c<58); c=gc())
x = x *10 + c - 48;
return x;
}

but when i used cin instead of this snippet my solution gets accepted.

@kevinsogo
Total number of test cases =10^5
Total Iterations in subtask1=10^9

But we are allowed only 10^8 iterations , so how this code is running, can anyone help??

thanks for the message this helped me a lot,kudos!

Following is my CPP code. what am I doing wrong?
Not even first subtask is correct.

``````#include <iostream>
using namespace std;

int main() {
int t, x, y, k, n, pi, ci;
bool found;
cin >> t;
while(t--){
cin >> x >> y >> k >> n;
found = (y >= x) ? true: false;  // current book is enough.
while((n--) && (!found)){
cin >> pi >> ci;
if((ci <= k) && (pi >= (x - y))){
found = true;
}
}
if(found)
cout << "LuckyChef" << endl;
else
cout << "UnluckyChef" << endl;
}
return 0;
}
#include <iostream>
using namespace std;

int main() {
int t, x, y, k, n, pi, ci;
bool found;
cin >> t;
while(t--){
cin >> x >> y >> k >> n;
found = (y >= x) ? true: false;  // current book is enough.
while((n--) && (!found)){
cin >> pi >> ci;
if((ci <= k) && (pi >= (x - y))){
found = true;
}
}
if(found)
cout << "LuckyChef" << endl;
else
cout << "UnluckyChef" << endl;
}
return 0;
}``````
``````#include <iostream>
using namespace std;
int main() {
int T;
cin>>T;
for(int i = 0; i < T; i++){
int X,Y,K,N;
cin >> X >> Y >> K >> N;
bool luck = false;
for(int j =0; j < K;j++){
int p,q;
cin>>p>>q;
if(q <= K & p >= (X-Y)){
luck = true;
}
}
if(!luck){
cout<<"UnluckyChef"<<' ';
}else{
cout<<"LuckyChef"<<' ';
}
}
return 0;
}
``````

i cant understand whats wrong with this code.