3538 - Newton's Apple

The forum to report every bug you find or tell us what you'd like to find in Live Archive

Moderator: Board moderators

3538 - Newton's Apple

Postby Enric » Mon Sep 28, 2009 11:49 pm

The first line of some cases is wrong. It should be the number of test cases, but the number is split using spaces or other whitespaces.

If I just did:
Code: Select all
cin >> cases;

it returned Output Limit Exceeded, because it entered an infinite loop.

What I had to do is:
Code: Select all
string s;
    string aux;
    getline(cin, aux);
    int k = 0;
    for (int i = 0; i < aux.size(); ++i) {
        if (isdigit(aux[i])) {
            k *= 10;
            k += (aux[i] - '0');
        }
    }
    while (k-->0) {



So probabbly the number of cases is written like this.
If there are 1578 cases, the input is:
1 57 8

I hope you fix it soon!

Thanks,
Enric S. Cusell
Enric
New poster
 
Posts: 1
Joined: Mon Sep 28, 2009 11:38 pm

Re: 3538 - Newton's Apple

Postby Carlos » Thu Oct 01, 2009 10:31 pm

That particular number is right. Could it be that you're trying to read beyond the end of the file?

Btw, I've deleted a spureous empty line at the end of the input file, but that should be no problem since you must stop reading before that empty line is even read.
DON'T PM ME --> For any doubt, suggestion or error reporting, please mail to:
acmicpclivearchive@gmail.com
User avatar
Carlos
System administrator
 
Posts: 634
Joined: Sat Oct 13, 2001 1:00 am
Location: Valladolid, Spain


Return to Bugs and Suggestions

Who is online

Users browsing this forum: qrefodfggrea and 1 guest

cron