SAKT's blog

By SAKT, 10 years ago, In English

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 ... ?

  • Vote: I like it
  • -11
  • Vote: I do not like it

»
10 years ago, # |
Rev. 2   Vote: I like it +3 Vote: I do not like it

I was wrong, my bad

  • »
    »
    10 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    Yes, But he just sorts array a.
    Array b is in order of input.

    • »
      »
      »
      10 years ago, # ^ |
        Vote: I like it +5 Vote: I do not like it

      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:

      3
      2 1 
      1 2 
      3 3
      
      • »
        »
        »
        »
        10 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Oh! Thank you very much!
        Anyway, The tests were very very very weak! I saw a lot of incorrect codes that got ACC.

»
10 years ago, # |
  Vote: I like it +13 Vote: I do not like it

7381353 And I wonder how this got AC

  • »
    »
    10 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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?!

  • »
    »
    10 years ago, # ^ |
    Rev. 2   Vote: I like it +19 Vote: I do not like it

    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).

  • »
    »
    10 years ago, # ^ |
      Vote: I like it +11 Vote: I do not like it

    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.

  • »
    »
    10 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    I lost points on challenging such solution, because system invocation hadn't returned answer back to me :(

»
10 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

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 )