Common hacks / tricks we can learn from

Правка en1, от alfaloo, 2025-01-14 04:49:50

Hello, hope you are all well. As a fellow Codeforcer, I hate the feeling when my code gets hacked or stuck on a private test case for a trivial reason. Thus I wanted to create this thread where everyone is encouraged to share some niche case where their code unexpectedly broke :(

I'll start first: - In the Hello 2025 problem A, my unordered hash structure got TLE hacked. Solution is the use a custom hash function, courtesy of Neal's post. - In Codeforces Round 996 problem D, I tried printing a double to console in cpp. For large values, doubles defaults to scientific notation (e.g. 1.2345e+7), so I was stuck on that private test case for the whole contest :(. Solution is to cast the result to int or long long before printing. - I've read somewhere that sqrt and log functions can have precision issues at large values? I've never encountered an error when using them so far though.

I hope my mistakes are helpful to you all :)

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский alfaloo 2025-01-14 04:50:32 6
en1 Английский alfaloo 2025-01-14 04:49:50 1125 Initial revision (published)