where did i went wrong?

i wrote this code for snackup but i dont know which test cases it failed can anyone help;

Your output is:

1 1 2
2 2 3
3 1 3
1 2 3
2 1 3
3 1 2
1 1 3
2 1 2
3 1 2

3 has not have had the 3rd dish 2 times.



Have a look at my solution if you want any assistance. :smiley: :smiley:


You need not have to over complicate your code than necessary by introducing so many loops. Then problem basically asking to iterate through all of the dishes just twice.
Below is my code for a very simple implementation.


1 Like

Error- You are thinking way too complicated for a simple problem. 15 minutes of pen and paper led me to have a very important observation, which would make life simple for solving this problem. Try to analyse Q a bit more, because jumping to solve Q right away will most probably lead to WA (or TLE)

Solution of the problem- Copying what i wrote earlier-

The problem statement was purposely made large to make participants think of it as a hard problem. (Due to which i SKIPPED doing it till end...GOSH!!)

The problem said that, you can organize ANY number of rounds, inviting ANY number of judges (upto N, of course). Every round, Ada will make 2 x k dishes dishes. Every dish must be eaten, and a judge cannot eat same dish twice, AND a judge cannot eat more than 2 dishes.

At the end of all the rounds, the statistics should be such that EVERY JUDGE TASTED EVERY DISH EXACTLY TWICE.

What i came up with, was to hold N rounds, invite ALL N judges, and make then eat dishes as-

For 1st round-

Judge 1-  (1,2)
Judge 2- (2,3)
Judge 3- (3,4)
Judge N-1 - (N-1,N)
Judge N - (N,1)

For second round-

(Shift the order of dishes 1 place up)

Judge 1 -(2,3)
Judge 2- (3,4)
Judge 3- (4,5)
Judge N-1 -(N,1)
Judge N- (1,2)

Do this for all N rounds.

This is one of the easiest solution to this problem. I hope i made the pattern clear. In case of any further doubts, let me know ^^

Can you explain your solution briefly?