MAXTOPO HELP

well u can read the problem statement here :

I did the same mentioned in editorial ( a little bit different to generalise for every value of k )

From editorial :
rootans = parentans * ( my size) / ( N - mysize )
so i just rerooted the tree and found the answer for children by induction what we usually do in DP on tree/rerooting

but the problem is i am getting only 10 points rest all of them are WA don’t know why

SUBMISSION LINK : CodeChef: Practical coding for everyone

can you help me to figure it out
i already devoted 3-4 hours but still not get out of it ( u can see my submission deadlines )

Expecting u for help

@chefback , are you storing the number of topological sortings of every node ??

yes i am

@infinite_king yes i am

if your are calcuating (number of TS) % mod , and than after doing sorting , then that will gives us the wrong answer.

It is because you are storing \%MOD values. In the first subtask, N \leq 10, so that MOD has no effect, however, when answer becomes more than MOD, your solution sorts them by \%MOD values which is wrong.

1 Like

so according to question i have to calculate the original MAX TS not the moded MAX TS?

got it thanks guys :slight_smile:

@infinite_king @samarth2017

1 Like

yes