WA Because Of Fastscan()

Link to Question : https://www.hackerrank.com/contests/lets-code-qualifier-2k17/challenges/panda-and-his-laziness

Link to Answer getting WA : https://ideone.com/RRSIWD

Link to Answer getting AC : https://ideone.com/FEq5ut

Just removing Fastscan() Gives AC .

Can’t Figure out Why???

Your fastscan() function is not entirely correct. It will not behave in the expected manner if there are more than two junk characters (not a digit or "-") between 2 integers, such as a line ending with "\r\n" instead of "\n". You could change it to something like this which assumes all characters less than ASCII 48, which includes common whitespace characters, are junk and skips over them.

void fastscan(ll &x) {
    ...
    x = 0;
    while((c=getchar()) < 48);
    if(c == '-') {
        ....
    }
    ....
}
2 Likes

Yeah!! It worked !!
Thanks!!

//