Please read the new rule regarding the restriction on the use of AI tools. ×

aastik231205's blog

By aastik231205, history, 4 hours ago, In English

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.

  • Vote: I like it
  • -9
  • Vote: I do not like it

»
4 hours ago, # |
Rev. 4   Vote: I like it 0 Vote: I do not like it

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 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

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.