trunghieu11's blog

By trunghieu11, 11 years ago, In English

In problem http://codeforces.com/contest/296/problem/C I try to create a test for hacking, but I get error "Invalid input". I don't know why my code get this error. Please help me, here's my code:

int main() {
    cout << "100000 100000 100000\n";
    for (int i = 0; i < 100000; i++) {
        if (i)
            cout << " ";
        cout << "100000";
    }
    cout << "\n";
    for (int i = 0; i < 100000; i++) {
        if (i)
            cout << "\n";
        cout << "1 100000 100000";
    }
    cout << "\n";
    for (int i = 0; i < 100000; i++) {
        if (i)
            cout << "\n";
        cout << "1 100000";
    }
    cout << "\n";
}
  • Vote: I like it
  • +5
  • Vote: I do not like it

»
11 years ago, # |
  Vote: I like it -8 Vote: I do not like it

It's because you have a " " at end of your 2nd line & you have some additional Enters at end of your 2nd and 3nd for! I guess this code is working correctly:

int main() {
    cout << "100000 100000 100000\n";
    for (int i = 0; i < 100000; i++) {
        if (i && i-99999)
            cout << " ";
        cout << "100000";
    }
    cout << "\n";
    for (int i = 0; i < 100000; i++) {
        if (i && i-99999)
            cout << "\n";
        cout << "1 100000 100000";
    }
    cout << "\n";
    for (int i = 0; i < 100000; i++) {
        if (i && i-99999)
            cout << "\n";
        cout << "1 100000";
    }
    cout << "\n";
}

& it's my code for this hacking :


long long asli = 100000; int main() { cout << asli <<" " << asli << " " << asli << endl; cout << 1; for(int i=1;i<asli;i++) cout << " " << 1; cout << endl; for(int i=0;i<asli;i++) cout << 1 << " " << asli << " " << 5 << endl; for(int i=0;i<asli;i++) cout << 1 << " " << asli << endl; }

Sorry for my terrible English!

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

    thanks you so much! :D

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

    Original generator doesn't output anything unwanted. So it is not a reason of "Invalid input", but I don't know what is wrong.

    With your changes there is no space before last number in 2nd line. ("... 100000 100000 100000100000")

    Also at the end of file will be:

    ...
    1 100000
    1 1000001 100000
    
    • »
      »
      »
      11 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Yes, you are right! Thank you!

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

      Oh! I see, thank you so much, I still can't find what wrong with my test :D

»
11 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Can you please get validator comment? It's text in box, which opens if click "Invalid test" link on your hack.