ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1098. Questions

IO tips and other
Posted by lakerka 3 May 2015 20:43
First of all make sure that you are not reading newlines and carriage return symbols. Input can be read like:

    char c;
    int scanfRez;
    do {
        scanfRez = scanf("%c", &c);
        if (scanfRez != EOF && c != '\n' && c != '\r') {
            chs[chCount++] = c;
        }
    }while(scanfRez != EOF);

I was getting WA7 with this input reading:

    char c;
    int scanfRez;
    do {
        scanfRez = scanf("%c", &c);
        if (c != '\n' && c != '\r') {
            chs[chCount++] = c;
        }
    }while(scanfRez != EOF);

If you get WA3 make sure that you are processing sequence correctly with given sequence length > N. For example:
let N = 11, input sequence = "abcdefghijkl" (without quotes) then letters should be removed in this order:
k 1
j 2
l 3
b 4
e 5
i 6
g 7
h 8
d 9
a 10
c 11
f 12

It does not matter if you put newline at the end of output.