I met with some weird problems when solving https://codeforces.me/contest/1599/problem/C The question is simple, but plz take a look at these 4 submissions below:
Case 1:
https://codeforces.me/contest/1599/submission/133010155
https://codeforces.me/contest/1599/submission/133010068
The only difference is the "inline" of the function double mypr
.
Take a look at the test cases for more information.
Case 2:
https://codeforces.me/contest/1599/submission/133012557
https://codeforces.me/contest/1599/submission/133012618
The only difference is the "cout" line in function int solve
.
Also take a look at the test cases for more information.
Compiler: GNU G++14 6.4.0
Everything works fine on my local environment, G++11/14 or else.
So is there any problem with codeforces, or is it my fault?
Auto comment: topic has been updated by zhugezy (previous revision, new revision, compare).
Worse still, I got AC when I copied your WA code in Case 1 and ran it on C++20, but it would be wrong in C++17... https://codeforces.me/contest/1599/submission/133026237
Could it be the implementation?
I got an AC with
#define double long double
just now, so absolutely there is precision loss here... but it's still confusing thatinline
orcout
could get the result modified.https://codeforces.me/contest/1599/submission/133032524
Observing The Universe Really Does Change The Outcome, And This Experiment Shows How
When you use cout, you "observe" it, I think it has something to do with Quantum Entanglement.
was just taking consideration of this theory XD
And YOU hate NERDs?
I think the WA is caused by this line
if (temp >= p) return m;
. When temp is equal to p, the judgment may still be false due to the precision of floating point numbers,You show that gcc is not stable when compiling different codes, although their logic is exactly the same. So I guess it will pass by changing the code like this
if (temp >= p - 1e-6) return m;
. 133048370So looks like it's some kind of compiler issues leading to different compiling behaviours. May try going deep into it.
Very useful, thx!