Hi Codeforces.
I had just 2 problems with the last contest (Codeforces Round 260 (Div. 2)).
First, Look at this submission (7380851) for this problem (456B - Fedya and Maths). On the 11th line, there is this if:
if(s == "1")
cout << 1 << endl;
It says that if the input was "1", the answer is 1. But obviously, it's wrong! If input was "1", the answer should be 0!
But this code Accepted.
Why? Really this much weak tests?!
Can anybody help that I am wrong and the code is correct or ... ?
Second, Look this submission (7382564) for this problem (456A - Laptops).
In my opinion, This code is wrong because of this line:
for (int i=0; i<n; i++)
if (b[i]>b[i+1] && a[i].F!=a[i].S) {cout<<"Happy Alex"; return 0;}
It says that it never cout "Happy Alex" unless there exists an i that b[i] > b[i+1]
And if we pay attention to the way he is filling his b array:
for (int i=0; i<n; i++)
{
int x,y;
cin>>x>>y;
a[i]=make_pair(x,y);
--> b[i]=y;
}
we realize that this code should output "Poor Alex" for this test because for every i, we have b[i] < b[i+1] :
3
2 1
3 2
1 3
I tried to hack him with the same test but I got an "Unsuccessful hacking attempt"
Can anybody help that I am wrong and the code is correct or ... ?
I was wrong, my bad
Yes, But he just sorts array a.
Array b is in order of input.
Yes, you are right. This submission is incorrect indeed, however, it gives correct answer to your hack because "for" works until i < n, and when i == n — 1, b[i + 1] == b[n] == 0, as a consequence your hack was unsuccessful.
Hack test:
Oh! Thank you very much!
Anyway, The tests were very very very weak! I saw a lot of incorrect codes that got ACC.
7381353 And I wonder how this got AC
Wow!! It's obviously opossite of the problem statement:
e.g. it can exceed any integer type of your programming language
What kind of contest was this?!
It looks like it depends on
scanf
implementation. It is logical that reading big integer causes overflow, which can be interpreted as taking input modulo 264. This does not affect answer (though I would not recommend to rely on that effect).It seems this guy is extremely lucky. His solution takes the input number modulo 264 unintentionally and then modulo 4 which is the divisor of 264 and thus doesn't change the result.
http://ideone.com/7hnPWp
they all truncate to 2^63 — 1. Why would compiler do modulo?
It's an undefined behavior. My MSVS 2012 takes long numbers modulo 264. It seems to be a compiler-based luck.
Try to run it here on Codeforces...
Thanks. This is extremely lucky.
I lost points on challenging such solution, because system invocation hadn't returned answer back to me :(
This is my code for problem C , if we have 50,000 numbers in form ( a1 , a2 , ... ) so that ( a2 != a1 + 1 & a3 != a2 + 1 & ...) my program Set's memo for 50,000 times , and it should be TimeLimit but i got AC(i'm so lucky && weak test case )