For the given example 12 is the minimum possible sum
Some hints I received for this problem is to use Kosaraju's algorithm to find labels, then build a scc (strongly connected component) graph. From there, you can calculate which routes would yield the optimal route that reduces as much edges to its minimum, and then calculate the minimum sum.
I understand this idea, but I don't know how to code it, so I'm relying on you. Hopefully this tip helps. Also, feel free to ask to change this order to a medium task.
For the code, you are using a while loop to read the inputs line by line. It's not needed. The inputs will always just be integers, so there's no need to read it as a line and will always have m+2 lines worth of inputs, with the first line being 2 inputs for value n and m, and the final line being the weights for every ai portals.
Also, there's no need to check for exceptions, so please do remove the print statements for "try again" and such.
Some hints I received for this problem is to use Kosaraju's algorithm to find labels, then build a scc (strongly connected component) graph. From there, you can calculate which routes would yield the optimal route that reduces as much edges to its minimum, and then calculate the minimum sum.
I understand this idea, but I don't know how to code it, so I'm relying on you. Hopefully this tip helps. Also, feel free to ask to change this order to a medium task.
The bin zlmszq6lrsr2c9hj was created 32 seconds ago, updated 1 second ago and it expires 6 days from now. It contains 3 uploaded files at 8.7 MB in total
Project ID:FS-11044-kazi
I'm proficient with java and am experienced in linear time algorithm. I will do a perfect job
I'm proficient with java and am experienced in linear time algorithm. I will do a perfect job