How can I remember the results of isPrime()? for n = 10000, I have to check whether n*n + n + 41 is a prime number. So far I know, I can't declare so big array :
I tried my best but could not get this problem AC within the time limit, let alone with a good timing... Please just have a look on my code and tell me how I can get this problem AC with a good timing.
I also considered disconnected graph. But I didn't consider the "ambiguous case" mentioned above. Now I am trying to fix (??) it accordingly. Thanks for your help, dear Jalal!
The officials from TLC realized that in such a case it can happen that besides the fact that the place with the failure is unreachable, this can also cause that some other places cannot connect to each other. In such a case we will say the place (where the failure occured) is critical. Now the ...
Can anybody please help me me with some input and output? I have tried this problem but have got WA. It's a problem of finding articulation point, isn't it? Is there any tricky test case?
I tried to solve this problem using Extended Euclid Algorithm. But got TLE. I think I could not optimize the solution properly. Can anybody share his algorithm as to how he minimizes the cost after getting a solution by Extended Euclid Algorithm?
Thanks a lot, Raiyan Kamal. I managed to handle the error and fixed the code and got AC :) . The answers for your test cases follow: Sector #1: contain 1 freedom fighter group(s) & 0 enemy group(s) Sector #2: contain 0 freedom fighter group(s) & 1 enemy group(s) Total 0 group(s) are in fighting ...
When I got WA for the first time in this problem, I visited the previous discussions on this one. Some tricky input-output were given there and my solution code was right for them. But I still can't understand what wrong is with my code. I couldn't find out the bug in my code though I tried couple ...