On the last contest I have send identical code on compilers for all 3 versions and while I got time limit on ++17 and ++14, on ++20 it took slightly more than a second(twice as fast). Is C++20 that effective or how else that can be explained?
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
On the last contest I have send identical code on compilers for all 3 versions and while I got time limit on ++17 and ++14, on ++20 it took slightly more than a second(twice as fast). Is C++20 that effective or how else that can be explained?
Name |
---|
What was the code?
https://codeforces.me/contest/1716/submission/167002044
Your code uses
long longs
(64-bit integers) everywhere, so c++20 (which is 64-bit) will be faster than 32-bit versions. I suspect that if you run with c++17 64, it'll be about as fast as c++20.There should be a tangible performance difference between 64-bit and 32-bit compiled code, specially if your program uses 64-bit numeric data processing extensively and the compiled code is running on a 64-bit microprocessor.
Thank you. Am i right to understand that code on c++14 and c++17 is always 32 bits or i can change that somehow
With pleause.
RE: Your question
This depends on the compilation flags passed to the g++ compiler.
Check the following old blog about that issue.
About the programming languages
The Codeforces technical administration team should be able to confirm that the GNU c++14 and c++17 compilers generate 32-bit executable code by default, as I expect.
Note that the among the g++ compilation flags is the -m switch, which allows changing the default target architectural model used to generate the object code. Using -m32 should generate 32-bit executable code, and using -m64 should generate 64-bit executable code.
On the other hand, I checked your code, and found that it uses 64-bit integers extensively, as I expected. You may check the following update to your code, which was accepted using c++14.
167158251
Is there any guide you know which shows how to use them(I found how to set them in editor but how to "explain" that to Codeforces compiler)? In fact I have never heard about them before so that topic is probably not sufficient to me
What do you mean by "them"?
Are you referring to the g++ compilation flags?
Yes
The official reference that I often consult is the GCC Command Options of the GNU Compiler online documentation.
Using the GNU Compiler Collection (GCC)