Was solving this Cses problem from graph section.I came up with a dp approach for this but getting wrong answer on three testcases.Can anyone help me in where i am going wrong. Here is my submission
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
Was solving this Cses problem from graph section.I came up with a dp approach for this but getting wrong answer on three testcases.Can anyone help me in where i am going wrong. Here is my submission
Name |
---|
Flight discount is a template problem for this algorithm:
Dijkstra
I can't open Ideone links, could you use another method of sharing such as linking to your submission on cases or posting to Pastebin?
Given that the intended solution is the algorithm above, I'm not sure how you can solve it with a dp approach, but I am really interested to see your approach!
here
Your dp fails at this case
do[4][0] will be 1e18 instead of 3. Your dp fails on cycles, such as the example I gave. You need to run Dijkstra's algorithm to solve this problem. CP algorithms has a very good tutorial on it.
His code may be wrong, but the test case you gave is running perfectly fine.
It's numbered from 0 to n-1, but the problem gives numbers from 1 to n. If you add 1 to every element, his code outputs 62, which is incorrect, since there's a path that costs 54. Here's the fixed test case:
Here's an illustration fo the graph. You use the coupon on the edge from 1 to 2, then follow the path 1, 2, 5, 3, 4, 6.
My submission getting TLE on Test 18 can someone help me with my code where can I optimize this code submission
Same I got all the test correct except Test 18. Even after all optimisations, I was unable to resolve it.
https://codeforces.net/blog/entry/132653