Codeforces celebrates 10 years! We are pleased to announce the crowdfunding-campaign. Congratulate us by the link https://codeforces.com/10years. ×

By adarsh000321, history, 4 weeks ago, ,

Hello Codeforces, I actually have two codes (69520703 and 69521121) that are doing the same thing but i just changed the order of the states and one of them is giving TLE (at test case: 78)and the other got AC. Can you please help me out. Dislike if you want but please reply :)

• +12

 » 4 weeks ago, # |   0 Could Someone take a look at it. I've been stuck here for more than 4 hours. Please
 » 4 weeks ago, # |   +10 I'm guessing cache.
•  » » 4 weeks ago, # ^ |   0 Thanks for giving me the problem name. I'll read about it.
•  » » 4 weeks ago, # ^ |   0 Thanks. You are right. Its a cache.
 » 4 weeks ago, # |   +10 Cache friendliness is one possible reason.Another reason would be that in Java, memory of a multidimensional array are not allocated in a contiguous block, so new int[a][2] would create a small blocks of memory each contains a int[2]. In comparison with new int[2][a], that's a lot slower.new int[2*a] should be faster (but also harder to read)
•  » » 4 weeks ago, # ^ |   0 Thanks for the link. You're a savior. :)