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

Обсуждение задачи 1684. Последнее слово Джека

For everyone who thinks that his solution( C++ ) is correct, but has TLE..
Послано PersonalJesus 8 сен 2009 23:01
Do NOT use STL's strings, use standart C char arrays instead. That makes a HUGE difference in the time and memory complexity. I hope that this will be helpful to somebody:)
Re: For everyone who thinks that his solution( C++ ) is correct, but has TLE..
Послано fmm 20 июн 2010 05:32
i disagree, my solution takes 0.046 seconds...
and i use string, vector
Re: For everyone who thinks that his solution( C++ ) is correct, but has TLE..
Послано 2rf [Perm School #9] 25 июл 2010 21:32
PersonalJesus писал(a) 8 сентября 2009 23:01
Do NOT use STL's strings, use standart C char arrays instead. That makes a HUGE difference in the time and memory complexity. I hope that this will be helpful to somebody:)

STL string - TL 12, 10 MB used.
Char arrays - AC 0.031, 1.24 MB used...
Re: For everyone who thinks that his solution( C++ ) is correct, but has TLE..
Послано IgorKoval(from Pskov) 14 дек 2011 16:09
I got TLE. But after changing "s1.size()" on "long ns1 = s1.size()" and "s2.size()" on "long ns2" got AC. =)
And I  changed "vector" on "deque"( for deleting elements from begining ).

Edited by author 14.12.2011 16:27

Edited by author 14.12.2011 16:30
Re: For everyone who thinks that his solution( C++ ) is correct, but has TLE..
Послано ASK 30 янв 2014 23:22
Got 0.062 and 1485 KB with pure STL and strings: just start your program with

 cin.sync_with_stdio(false);

Btw, to get a O(n) solution consider that if a suffix of the last word is a prefix of the first word (check thru hash), then it is safe to assume that this suffix is in the answer.