I submitted my code for 1612E - Messages in different C++ compilers and here are the results:
- C++14 — 138535056 — Accepted (1481 ms)
- C++17 (64) — 138534883 — TLE (3000 ms)
- C++17 — 138534840 — Accepted (1559 ms)
- C++20 (64) 138534744 — TLE (3000 ms)
All 4 are the same codes. I can understand that there can be minor differences in time taken, but here the difference is around 1.5 ms. I mostly code in python and don't have much idea on performance differences between different C++ compilers.
As far as I can think, int
operations are faster in C++ while long long
operations are faster in C++ (64). But still, the difference is huge. Is there any other reason and how to decide appropriate C++ compiler?
Changed your for loop on line 20 to iterate over your map using references so you don't create copies of all the items, runs in 904 ms on C++ 20 (64). 138860478