Codeforces Round 1133 (Div. 1, Div. 2) is coming soon! Register here. ×

trunghieu11's blog

By trunghieu11, 14 years ago, In English

In problem http://codeforces.me/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

»
14 years ago, hide # |
 
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!

»
14 years ago, hide # |
 
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.