Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя aastik231205

Автор aastik231205, история, 4 часа назад, По-английски

There seems to be quite bad limits set in problem A of the recent contest such that a brute force approach is passing using one set of operations but getting TLE using another set of operations both giving same Big O complexity. The two submissions are :-

Here is the submission getting TLE and here is the one getting Accepted.

Literally the only difference is that in one code there is an extra division in place of many multiplications in the TLE submission. Look I know integer division is slow but still either both of them should pass or both should fail.

  • Проголосовать: нравится
  • -9
  • Проголосовать: не нравится

»
4 часа назад, # |
Rev. 4   Проголосовать: нравится 0 Проголосовать: не нравится

try this case


1 1000000000 31623

the tle solution does the division a grand total of 31622 times PER test case

with 1e4 tests this would be 31 622 000 divisions which would easily TLE

update: i just checked, the AC sol takes 1500ms for 1e4 of those cases on C++17

it only took 484ms on c++20

update 2: the tle solution runs in 343ms on C++20

»
2 часа назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

This is a issue with G++ 17 complier , the code you mentioned (getting TLE) is getting accepted in G++ 20(283726791) with 312ms, i guess g++ 17 is very slow as compared to g++20 on E of same contest i was facing the same issue.

Learning :- using g++20 always.