Hello!
Can anyone tell me how to update my g++ compiler for C++ to the exact version that's used by the judge on codeforces? I'm using Windows 7 and I'm not using any IDE (i compile from the commandline). Currently I have g++ version 4.8.1 and I can't find where to download 5.1.0. Tried to download minGW but it keeps installing the old 4.8.1 version.
Before, I didn't care that the compiler versions didn't match, but this last competition (330 div 2) got me really pissed off. I figured out the solution to the B problem, but I kept getting WA on pretests. After the contest, I tried submitting the solution and I saw that my solution was giving the wrong answer on their machine, while I was getting the corrent answer on my PC. After some tweaking I figured it was the pow() function that was causing the trouble. After i manually calculated 10^k instead of calling pow(10,k), I got accepted.
This thing with different compiler versions is REALLY annoying and unpredictable because god knows how many more functions like pow() work differently on different compiler versions.
Also, what are the compiler options (like -Wall) used by the judge?
Thanks
If you are using Windows, you can visit PBOX, install it (as written on the home page). After it
pbox install mingw-tdm-gcc
will install exactly the same version of g++ as Codeforces uses. Also you can use it to install almost all software with exact version as Codeforces judging machines use.Thanks! That's actually very simple. I did as you said. Now when I write "pbox list-installed" I get version 5.1.0 but when i try "g++ --version" it still says 4.8.1. Am I doing something wrong?
You can try to restart cmd.exe session + remove your previous installation. You can execute
pbox install tools
to install many useful commandline tools (+ restart cmd) and run `where g++' to find the complete path to your old g++.I figured it out. I edited the "Path" environment variable and removed the old C:\MinGW. There was probably a collision with the old g++.exe and it always chose the old one. Now I get the 5.1.0 version when i write "g++" in the command line. Thanks alot!
thx, Mike.
in your case, compiler versions are irrelevant. Codeforces servers are much more sensitive to memory safety than your PC because they're under heavy workload. Write correct code (for example, add eps when dealing with floats) if you want to avoid this kind of errors.
So I was thinking, pow(10,3) probably returned 999.99999 and when I saved it to a long long, it gave me 999. I should have rounded it first. I think this was the whole problem. Still, I think updating the compiler is important