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

Обсуждение задачи 1362. Одноклассники 2

Optimization
Послано Pavlik 30 сен 2008 14:39
I accepted 0.39(5kb). I use template veckor class(C++) to store list of employees. But I don't know how make my program faster :(

Edited by author 30.09.2008 14:40
Re: Optimization
Послано Pavlik 30 сен 2008 14:47


Edited by author 30.09.2008 14:51
Re: Optimization
Послано Vedernikoff Sergey (HSE: EconomicsForever!) 2 окт 2008 00:46
Don't use vectors - these are VERY slow structures (as, by the way, all STL components). Rewrite with usual arrays - and, I think, speed of your code will increase several times...
Re: Optimization
Послано hoan 6 дек 2010 23:01
i use vector too, i think if i got use array memory limit have exceeded.
Re: Optimization
Послано Vlad 31 мар 2011 19:45
Vedernikoff Sergey (HSE: EconomicsForever!) писал(a) 2 октября 2008 00:46
Don't use vectors - these are VERY slow structures (as, by the way, all STL components). Rewrite with usual arrays - and, I think, speed of your code will increase several times...
This statement is just wrong.
Re: Optimization
Послано Vedernikoff 'Goryinyich' Sergey (HSE: АОП) 31 мар 2011 19:49
In which part? For any STL component I can write much faster analog.
Re: Optimization
Послано Vlad 2 апр 2011 01:53
Well, I was refering only to vectors. Of course you can make sets/maps/other stuff faster.

But the underlying structure of a vector is the same array.
E.g. vector<int> is just a {array pointer, size, reserved mem}.

I've heard this myth about vectors being slow several times, that's exactly why I've done some real testing of it - absolutely no difference, especially if you give the size beforehand (which you have to do in case of arrays).
Actually, if you use an iterator to iterate through your vector, it can sometimes actually be faster for different reasons.

The only difference may come from using multidimensional (i.e. nested) vectors - in that case, indeed, there can be some performance differences, but still, saying "VERY slow structures" is an extreme exaggeration... remember, you said "increase several times" :).


Edited by author 02.04.2011 02:12
Re: Optimization
Послано pmartynov 19 апр 2015 22:03
vector<bool> is slow.