Hacking C++ CodeForces solution

I code in JAVA. Recently, in a CodeForces contest, I went on hacking a solution and discovered a C++ code that might get an Array index out of bound error but it didn’t. Later found out that there is no array index out of bound error in C++ and needs to be taken care of while coding. Due to this, my hack was unsuccessful. Basically my question is what things I need to take care of while hacking if I code in other language? Do I need to start coding in other language? Most of the coders use C++ so I find it difficult to find a JAVA solution to hack.

That is correct, accessing an out of bounds index is “undefined behavior” in C++. So, unfortunately you cannot use that to predictably hack solutions. If you want to reliably hack solutions in other languages, you must be familiar with those languages.

Someone’s code had all integers while one of input was long long int… still his solution failed my hack and it passes system testing too !! How !!

Solution link : https://codeforces.com/submissions/vatsals1
Problem : https://codeforces.com/contest/1084/problem/B

Can anyone help ?

@I_returns it uses black magic.

#define int long long int

It replaces all occurrence of int with long long int.

3 Likes

Oh lol, I went through that code twice still didn’t see that :confused:

even I searched for #define int long long int
but I also didn’t see it XD