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
№ | Пользователь | Рейтинг |
---|---|---|
1 | ecnerwala | 3648 |
2 | Benq | 3580 |
3 | orzdevinwang | 3570 |
4 | cnnfls_csy | 3569 |
5 | Geothermal | 3568 |
6 | tourist | 3565 |
7 | maroonrk | 3530 |
8 | Radewoosh | 3520 |
9 | Um_nik | 3481 |
10 | jiangly | 3467 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | maomao90 | 174 |
2 | awoo | 164 |
2 | adamant | 164 |
4 | TheScrasse | 159 |
4 | nor | 159 |
6 | maroonrk | 156 |
7 | -is-this-fft- | 150 |
8 | SecondThread | 147 |
9 | orz | 146 |
10 | pajenegod | 145 |
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
Название |
---|
Your code gives WA as it does not stop on the path to one of the leaf nodes even after having greater than m consecutive vertices with cats,it refreshes the value of variable val to 0 on the same path and counts those leaf nodes as well.Example test case would be:
Input :
4 1
1 1 0 0
1 2
2 3
3 4
Output :
0 (but your code gives output as 1)
You can use a return statement to return from the path where greater than m consecutive vertices have cats.
Here is a link to my submission:39347359
Hey I couldn't understand why the answer is 2 in the second example shown in that problem.
The way I see it he can only go restaurant at vertex 5 through the path 1 -> 2 -> 5 which has only 1 cat. The path to 4, 6, 7 have 2 cats which exceeds the threshold.
Here is my code — https://pastebin.com/ws0frPRy
Thanks for your time !
Best Regards, Srivatsa
The question asks for consecutive vertices so the path to 4 is fine since the vertices with cats are not next to each other on the path.
In the sample example 1
we can't go to 2 but we can go to 3 and 4 why the ans is 2 and 2nd test
we can't go to 4 and 6 and 7 why ans is 2 may be i understood question wrong please help me