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 | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
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://mirror.codeforces.com/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)