Behaviour of two-dimensional array in C++

Revision en1, by mshcherba, 2016-08-31 13:51:17

Here are 2 solutions of the same problem: 20274603, 20298628. The only difference between them is two-dimensional array last. In first case it was last[MAXN][MAXQ], and in the second one — last[MAXQ][MAXN]. MAXN = 103 + 7, MAXQ = 105 + 7. I iterated only over that dimension, which has size MAXN. The first code is about 5 times slower. Could anyone please explain why? Thanks in advance.

Tags c++, arrays

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
ru1 Russian mshcherba 2016-08-31 13:57:50 466 Первая редакция перевода на Русский
en1 English mshcherba 2016-08-31 13:51:17 476 Initial revision (published)