help in codeforces problem 580/C (Kefa and park).

I am unable to get what is wrong with my logic.
The question link is here: http://codeforces.com/contest/580/problem/C

My solution is this: https://pastebin.com/DNgpJGnW

Did you even read the question or tried understanding it? It’s given cat count must not be greater than m in a path towards leaf. And also you should once look at editorials before asking for help . Just having a look at your code anyone would realise you didnt even care to understand the problem. Anyways your code fails in this testcase:

6 2

0 1 1 1 0 0

1 2

2 3

3 4

4 5

5 6

From next time please do ask for help only when needed.

with due respect soham1234, I want to tell you that i had read the question. also i had read the editorial my 11 test cases were running and on the 12 test case it failed. also it was a large test case so it was not fully visible so i can test my code on it.I will be careful next time when to ask for help.Thanks a lot soham1234.

Did you really read the editorial I highly doubt that. In your code you checked for consecutive m cats at leaf nodes and I don’t think the editorial has anything even remotely related to that. Please try making better excuses. I merely had a look at your dfs to figure out what was wrong

I am not making excuses and also i am not a very good programmer like a 6 star like you. And also what would i get by making excuses and asking for help.I was stuck at this for two days and that’s why i decided to ask for help.