I was trying to solve probem E from the last contest (542E - Playing on Graph) and I needed to solve all pairs shortest path problem. With n BFSs, It would be done in O(nm) but I'm too lazy to implement it! I saw 3 second time limit, so i used floyd-warshal and Bang... It just accepted in 1.7 second! 11022079
I tested my code on my machine without
-O2 with a simple 1000 vertex connected graph and it takes 15 seconds until my program answers, and with
-O2 it just takes 1.5 second!
I wrote another non-optimizable program with n3 running time (You can see it here) and with n = 1000 it runs in 12 seconds on my machine.
-O2 can optimize floyd! I wonder how it's possible?!
P.S. As I_love_Tanya_Romanova said, my second example is nonsense! :D
Anyway, could anyone explain how my solution is optimized?