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

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

Some hints (+)
Послано Dmitry 'Diman_YES' Kovalioff 27 июл 2004 12:35
I nearly hate this problem :) Two hours for coding and two days for troubleshooting - and, as usual, AC! I use the best Pascal compiler ever been - Delphi 7.0, but piracy-haters and opensource-admirers from the jury use FreePascal I dislike very much :( So during two days I have been solving a very interesting problem - "How to find the differences between Delphi and FreePascal without FreePascal itself?" ;) So some hints for Pascal-programmers:

1. Store the compressed text in such way:

const
   TEXT: AnsiString = 'compressedtext';

If you write

TEXT = 'compressedtext';

or

TEXT: String = 'compressedtext';

you'll get WA(1).

2. You should divide your compressed text into the parts of 255 symbols each:

TEXT: AnsiString = 'part1'+'part2'+...+'partN';

3. Your should replace the following symbols

#0,#10,#13,#26,#39

with their codes to avoid compilation error of your output and getting WA(1). BTW, I get WA(1) several times because of #26. The example of correct string:

TEXT: AnsiString = 'a'#0#39'bcdef'#26;

And be careful while replacing and dividing - this technical problem is not difficult, but pay attention to it.

P.S. As for my solution, I've used Shannon-Fano algo, and the compression rate was at least 50% - all the tests larger than 5 Kb were passed with flying colors.

Edited by author 27.07.2004 12:38
Re: Some hints (+)
Послано Vladimir Yakovlev (USU) 28 июл 2004 13:29
Dmitry 'Diman_YES' Kovalioff писал(a) 27 июля 2004 12:35
piracy-haters and opensource-admirers from the jury use FreePascal

Do you think piracy is good?
Dmitry 'Diman_YES' Kovalioff писал(a) 27 июля 2004 12:35
1. Store the compressed text in such way:

const
   TEXT: AnsiString = 'compressedtext';

If you write

TEXT = 'compressedtext';

or

TEXT: String = 'compressedtext';

you'll get WA(1).

2. You should divide your compressed text into the parts of 255 symbols each:

TEXT: AnsiString = 'part1'+'part2'+...+'partN';

I think you should use {$H+} directive in your source and archive and you get Delphi-like strings. (I wrote about this directive earlier)
Dmitry 'Diman_YES' Kovalioff писал(a) 27 июля 2004 12:35
3. Your should replace the following symbols

#0,#10,#13,#26,#39

with their codes to avoid compilation error of your output and getting WA(1). BTW, I get WA(1) several times because of #26. The example of correct string:

TEXT: AnsiString = 'a'#0#39'bcdef'#26;

To guess about this feature you should try to compile your archive on FreePascal just once! (Don't you do this after first WA(1)?)

P.S. This is wonderful problem, isn't it?
Re(2): Some hints (+)
Послано Dmitry 'Diman_YES' Kovalioff 29 июл 2004 09:39
>Do you think piracy is good?

Why should something be good or bad? Is a rain good? Or maybe bad? The sun? The Universe? The piracy is just inevitable natural phenomenon, the reflexion and the offspring of reality. I - and I bet you too - cannot deny it was piracy that curved our way to computers. Thanks to the piracy I am the Master of Computer Science. No offence, no holy wars :)

BTW, the thing was I believe Delphi is better than FreePascal...

>I think you should use {$H+} directive in your source and archive and you get Delphi-like strings. (I wrote about this directive earlier)

I know it works but $LONGSTRINGS (equal to $H) is ON by default in Delphi and I cannot understand why is it OFF in FreePascal.

>To guess about this feature you should try to compile your archive on FreePascal just once! (Don't you do this after first WA(1)?)

No, as I have said I haven't got FreePascal, so I couldn't compile my text with it. And in Delphi #26 is ok.

>P.S. This is wonderful problem, isn't it?

Yeah, it is. The most original problem in all the archive. But I think easy a bit. It would have been better to impose restrictions on the compression rate - I think 80% is enough to block bitshift-based solutions.
I got AC
Послано Фоминых Федор 4 май 2005 13:16
Many thanks for your helps. They have very much helped me.
But what for to use standard algorithms of compression (they not so difficult, but tiresome)? I am simple on each symbol spent on 7 bit. (Word is English, i.e. their codes from 1 up to 128).


Большое спасибо за твои подсказки. Они мне очень помогли.
Но зачем пользоваться стандартными алгоритмами сжатия (они не очень сложные, но нудные)? Я просто на каждый символ тратил по 7 бит. (Слова-та английские, т.е. их коды от 0 до 128).
Re: I got AC
Послано SPIRiT 7 авг 2006 17:41
How did You store them in the output file, hah?
Re: Some hints (+)
Послано partisan (Andrey Korotkov) 17 дек 2007 17:56
[quote]
2. You should divide your compressed text into the parts of 255 symbols each:

TEXT: AnsiString = 'part1'+'part2'+...+'partN';
[/quote]

How does it work? Delphi will compile such long string, but Free Pascal (2.0.4) doesn't (so we have to use arrays); I used C++ for archive, it can compile code with long strings; so how you aviod it (if avoid)?