Recently I've had my first hacked problem: 372051449. I didn't really think much of hacking up until this point, but this problem made me rethink. I have a few questions in mind:
What type of problems are most likely hackable?
What are the general methods used to hack a submission?
What preventive measures can be taken to protect a solution from hacks?
I'm interested in your ideas about hacking. Feel free to drop a comment!








Auto comment: topic has been updated by 2IA7A8E6A7 (previous revision, new revision, compare).
Bruh, even I can feel your pain, you missed that CM because of the hack.
I can think of mostly hashing problems and using hashtables (https://codeforces.me/blog/entry/62393) are easily hackable.
You could randomize your base to make it unpredictable
That's it I'm using SHA-256
You should use it on a high resolution clock for seed so its faster and you probably won't get hacked.
Maybe I'll just stick with splitmix64
Can you explain me how a problem gets hacked ? sorry idk this :)
You basically submit a test case that makes the code fail, like, for example the code runs on O(n^2) and you use a test case with n=1e6 to make it TLE, or have a bunch of inputs to attempt MLE
Usually, reading from a list is o(n) if you don't know the index because you need to search every item. However, in a hash map (which is a dict), a hash function is used on the item (modulo a number because it doesn't have to be very big) and that will be the index. This runs in o(1)
A hash collision hack is taking advantage that if 2 items have the same hash (and thus the same index), the program will have to read the entire list to find it (which is very slow compared to hash maps). With a lot of collisions, you can get time-limit on a problem.
use more and larger prime mods.
how bro
how bro
hacks should not be allowed in such questions i feel
This is an F problem though, I do like the idea of hacks, it encourages contestants to be more innovative to find the edge cases (this also applies to real-life applications)
Mostly hashing problems.
Add a random number to the base. Don’t use time(0) for seed, use chrono::steady_clock.
Has anyone ever hacked a non-hashing problem? If so, can you tell me about the process of hacking it?