# | 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 |
Name |
---|
I guess it's a compiler optimization
In your code if $$$g[i][j]$$$ is false, it won't do anything in the loop.
I guess GCC adds
if (!g[i][j]) break;
to the end of line 19Great, but this condition will never happen if the entire grid = 1
You're right, it might be because of random-access and you are defining vectors inside the function (i.e. heap/stack thing).
But I don't think so because I resubmitted with defining in global and no difference.
Thanks for your time, I think now you are curious too :D
Second code gets TLE'd because of some cache shenanigans.
My thoughts that CPU in first submit prefetches full cache line, so access to $$$newdp[mask]$$$ is almost free, but in the other submit, it can be washed out by accessing $$$g[i][j]$$$.
And AFAIK, arrays with len that are powers of two are quite bad for performance reasons on some CPUs, see this link for reference.
I thought that cache stuff don't affect complexity that much.
Now I got it thanks :D
Technically you're right. It doesn't affect the complexity at all. It does affect the constant factor though, which is what's causing the 2.5x speedup here.
No words come after yours sir.
similar thing has happened with me once on cf. i think it is due to more cache miss rate in second one but can't guess why it's happening