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

Обсуждение задачи 1307. Архиватор

Advices after almost a week spent on this task.
Послано prituladima 14 дек 2021 16:37
0. I wanted to implement universal approach with Huffman coding + compressing binary code to 64 base code. Not just eng text property (I was upset, because for so interesting task so stupid solution works).

1. I'm Java developer, and I afraid that Java consume too much memory even for input.
So I have to rewrite all to cpp.

2. Thinks that costs me a lot of time.
Input in cpp. (If you can explain what is wrong. please do )
WRONG
inputData = "";
std::string line = "";
while (std::getline(std::cin, line)) {
    inputData += line;
    //inputData.push_back('\r');//todo maybe we need \r\n
    inputData.push_back('\n');
}


CORRECT
inputData = "";
int c;
while ((c = getchar()) != EOF)
    inputData.push_back((char)c);

3. Escaping characters to produce cpp code:
std::string escape(char ch) {
    switch (ch) {
        case '\'':
            return "\\'";
        case '\"':
            return "\\\"";
        case '\\':
            return "\\\\";
        case '\b':
            return "\\b";
        case '\f':
            return "\\f";
        case '\n':
            return "\\n";
        case '\r':
            return "\\r";
        case '\t':
            return "\\t";
        default:
            return {ch};
    }
}

I finally got AC. So I wish you good luck with this problem and thank to author so interesting problem.