i have just started in competetive programming and i was solving the codeforces round #562

i was stuck for a long time and could not solve it can someone help me with this

thanks in advance.

link to the problem

https://codeforces.com/contest/1169/problem/B

1 Like

As you have not shared your approach, I’ll just give you the rough idea.

If a pair \{x, y\} exists, then every pair will have atleast one of them as per the question. So we can take 2 cases, both involving the first pair (a_1, b_1).

First assume that a_1 is x and then try to find y. If you get a valid answer you are done. Otherwise try with b_1 as x and again try to find y. If this fails then answer is “**NO**”

actually i dont nunderstand the editorial provided so i couldnot share my approach can you help me now

thanks bro

i coded a solution i submitted it but it is getting a wrong answer at test 7 dont know why please help me

this is my solution

https://codeforces.com/contest/1169/submission/54909077