I've used dfs, but it is giving me WA. Where i need to do correction? My solution
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 156 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
I've used dfs, but it is giving me WA. Where i need to do correction? My solution
Название |
---|
Have you tried the following:
Write a very naive and simple solution to the problem (maybe exponential complexity) (if you can, you may also just copy someone else's solution)
Write a program to generate thousands of small (!) test cases
Using those two, find a test case where your program gives the wrong answer
Use print statements or a debugger to see where exactly your program does the wrong thing.
98% of WAs and REs can be resolved this way. People here don't have time to delve into every code posted here, it's much harder to debug somebody else's code and being able to debug your own code is a valuable skill. It is also a very routine process that can be learned much faster than problem solving and algorithms.
Thank you for your advice. I have got my mistake!
In this problem, I have checked for one connected set, meanwhile there could be many connected set!