Блог пользователя SAKT

Автор SAKT, 10 лет назад, По-английски

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

  • Проголосовать: нравится
  • -11
  • Проголосовать: не нравится

»
10 лет назад, # |
Rev. 2   Проголосовать: нравится +3 Проголосовать: не нравится

I was wrong, my bad

  • »
    »
    10 лет назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

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

    • »
      »
      »
      10 лет назад, # ^ |
        Проголосовать: нравится +5 Проголосовать: не нравится

      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 лет назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

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

»
10 лет назад, # |
  Проголосовать: нравится +13 Проголосовать: не нравится

7381353 And I wonder how this got AC

  • »
    »
    10 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    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 лет назад, # ^ |
    Rev. 2   Проголосовать: нравится +19 Проголосовать: не нравится

    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 лет назад, # ^ |
      Проголосовать: нравится +11 Проголосовать: не нравится

    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 лет назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

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

»
10 лет назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

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 )