As the title suggests, I submitted the identical source code, which in my environment and in c++17 gives the right answer, but in c++14 it gives WA. I am aware this usually involves some sort of default initialization, but I believe my codes does not rely on that. I appreciate your help and insights as to what might be happening!
Two editorials for this problem, but I followed this one
Auto comment: topic has been updated by Jomax100 (previous revision, new revision, compare).
It is not guaranteed that
sz(id)
will be evaluated beforeid[a[i].u]
, until C++17.For more info: Order of evaluation
Huh, that's interesting. How did you find that?
Narut showed me this :D
Wow I never would have guessed that.
Thanks a lot!
You should write forn(h, sz(b)+1){ forn(u, sz(b)+1){ forn(v, sz(b)+1){ mmin(dp[u][v], dp[u][h] + dp[h][v]); } } } because your indexes are from 1 to sz(b),not 0 to sz(b)-1 After changing it got AC:57892426
Interesting fix. On my machine the ids started at 0. This must be the undefined behaviour mentioned by meooow