ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1226. йынтарбО кодяроп

I got WA on the test 2
Послано Bakhodir Boydedaev 4 сен 2017 00:42

Here is my code which has been written in java. Please help me. I cannot understand what wrong is. Or some tests you have ?. Thanks.

public class EsreveRredrO_1226 {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String s = reader.readLine();
        solve(s);
    }

    public static void solve(String s) {
        String text[];
        text = s.split(" ");
        for (int i = 0; i < text.length; i++) {
            String revers = "";
            String temp;
            for (int j = text[i].length() - 1; j >= 0;  j--) {
                    revers = revers.concat(String.valueOf(text[i].charAt(j)));
            }
            if (revers.charAt(0) == '!' || revers.charAt(0) == ',' || revers.charAt(0) == '.' || revers.charAt(0) == '?'
                    || revers.charAt(0) == ':' || revers.charAt(0) == ' ') {
                temp = revers.substring(1, revers.length());
                revers = temp.concat(String.valueOf(revers.charAt(0)));
            }
            if (i != text.length - 1)
            System.out.print(revers + " ");
            else System.out.print(revers);
        }
    }
}

Edited by author 04.09.2017 00:45
Re: I got WA on the test 2
Послано Mahilewets Nikita [BSUIR] 4 сен 2017 09:22
I remember the problem is quite a pain in the ass
I remember in that problem you should pay attention on all symbols

If there is new line \n\r you print so
If just \n you print \n

If there is no EOF you don't print EOF

I have not read your code

I have WA2 for a long time

And those symbols at the end of the line were related to those WA's
Re: I got WA on the test 2
Послано Mewtwo 31 окт 2017 23:14
Thanks for your words. I did care each symbol and didn't print any additional character at the end, and got AC. :)