(5B) Similar Method but Different Verdict — Runtime Error vs Accepted

Правка en2, от Kralc, 2015-08-18 09:41:08

When I was trying 5B, I get runtime error at the first time. I was frustrated since it works well in my computer. After observing the output from the judge, I suspected that there may be problem somewhere around the input handling part. So I re-wrote that part.

Original:

    int max = 0, i = 0, n;
    string in[1000];
    while(getline(cin, in[i])){
        if(in[i].size()>max)max = in[i].size();
        i++;
    }

Second version:

    int max = 0, i = 0, n;
    string in[1000];
    string tmp;
    while(getline(cin, tmp)){
        if(tmp.size()>max)max = tmp.size();
        in[i] = tmp;
        i++;
    }

It is accepted and I have no idea why....

Теги center alignment, mysterious runtime error

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский Kralc 2015-08-18 09:41:08 407 Tiny change: 'riginal:\n~~~~~\n ' -
en1 Английский Kralc 2015-08-18 09:38:33 582 Initial revision (published)