# How to solve Game of Numbers from MNM 2018?

Can someone explain their logic for the problem?

I wonder how it had 10 times more submissions than the much easier second problem.

It is a copy of spoj problem â€śPlay on Wordsâ€ť. U can have a look at solution here it is pretty much clearly written except there letters are used and here numbers are used

Even at the second problem they doesnâ€™t give the constraints. I assume the constraints 2<=n but in some test cases they are n<2 which doesnâ€™t have any meaning with respect to questions. Even i asked this question and i amazed with such there reply. They said â€śit is an integer that it. It is up to youâ€ť. Its ok its an integer but you should properly define it because integer can be so large even 10^100 is an integer. It wasted lots of my time. Now i will never participate in these kinds of contest. I know its very difficult to design problems but still they need to take care of these things.

link to my solutionâ€¦
https://www.codechef.com/viewsolution/17564528

logic :
i have just created a hash table which contain frequency of first and last number of any integer ( 786 hsh[7]++,hsh[6]++),
and i have considered a number which are less than 10 as a 2 digit number ( 7 , hsh[7]++,hsh[7]++ ) assuming this digit as starting and ending for the sequenceâ€¦
and finally all even frequency digit will involve in sequence and a odd frequency number may be starting and terminating digit of first and last number so if odd frequency number is more than 2 then not possible else possible.
plz reply if u have any doubt.

Thanks for the link! Many of the submissions did not even consider the disconnected graph thing and still managed to get AC. Weak test cases perhaps.

1 Like

Your code fails in this test case:

1

5

12

21

13

31

77

Expected: No