[Logo] Форум DL
  [DL]  На главную страницу 
Индекс форума ->Олимпиадное программирование ->Обсуждение теории 1, 2
Автор Сообщение
Михаил Долинский

Темы: 1984
Сообщений: 47242

Мой профиль
Both methods immediately leads to a O(nlogn) time solution using balanced binary trees.

Sorry to all the Pascal programmers as STL set gives C++ users a huge advantage should this solution be implemented.

Это цитата из анализа задачи USACO 2007 January Gold: Problem 3. Cow School
Михаил Долинский

Темы: 1984
Сообщений: 47242

Мой профиль
Under C++, the algorithm can be implemented using the STL priority_queue in O(NlogN) time.

Это цитата из анализа задачи USACO 2006 November Gold: Problem 1: Fence Repair
Михаил Долинский

Темы: 1984
Сообщений: 47242

Мой профиль
The C++ Standard Template Library has a handy function called next_permutation that takes care of all the work in looping over the possible permutations.

Это цитата из анализа задачи USACO 2007 March Bronze: Problem 3: Cows of the Round Table
Михаил Долинский

Темы: 1984
Сообщений: 47242

Мой профиль
However, if you really do not like coding data structures from scratch (due to bugs or just plain boredom), then it is worth the effort to learn to use your languages libraries for data structures. Below is a (short) solution from Christos Tzamos that uses STL's map and multiset, which are already sorted containers!

Это цитата из анализа задачи USACO 2007 April Silver: Problem 1: City Horizon

Михаил Долинский

Темы: 1984
Сообщений: 47242

Мой профиль
Курс лекций по олимпиадному программированию Михаила Густокашина

http://moemesto.ru/tnik222/file/4587241/lection2.pdf


С лекциями, задачами с тестами, и их разборами.
...
Занятие 5: STL

Введение.
Пара (pair).
Стек (stack).
Очередь (queue).
Дек (deque).
Динамически расширяемый массив (vector).
Вектор битов (bit_vector).
Строка (string).
Итераторы.
Хеш-таблица (hash_set).
Хеш-словарь (hash_map).
Алгоритмы в STL.
Использование собственных структур в STL.
Михаил Долинский

Темы: 1984
Сообщений: 47242

Мой профиль
Хорошая дока по STL (на английском):
http://www.sgi.com/tech/stl/table_of_contents.html
Михаил Долинский

Темы: 1984
Сообщений: 47242

Мой профиль
Now the problem becomes a data structure problem, we need to support the following operations: insertion, deletion, find the first element with key bigger than a given value and we want to do each operation in O(logn) time This can be done using STL set.

Это цитата из анализа задачи USACO 2007 December Gold: Problem 2: Gourmet Grazers
Михаил Долинский

Темы: 1984
Сообщений: 47242

Мой профиль
This one is slightly complex owing to the requirement for a 'sort' routine. C and C++ programmers have easily used built-in sort routines (e.g., qsort); Pascal and Java

Это цитата из анализа задачи USACO 2008 January Bronze: Problem 2: Election Time
Михаил Долинский

Темы: 1984
Сообщений: 47242

Мой профиль


Евгений Грицкевич:

... Есть алгоритм, который позволяет найти K-й по счёту в отсортированном массиве элемент быстрее чем за NLogN (в Си++ это nth_element() ) .  
Михаил Долинский

Темы: 1984
Сообщений: 47242

Мой профиль
Both C++ and Java have priority queues in their standard library.

Это цитата из анализа задачи 2010 February Silver : 2. Chocolate Giving
Михаил Долинский

Темы: 1984
Сообщений: 47242

Мой профиль
C++.com
Михаил Долинский

Темы: 1984
Сообщений: 47242

Мой профиль
are stored in a data structure that can quickly find the min and max, such as an STL multiset

2012 March Silver : 2. Flowerpot
Михаил Долинский

Темы: 1984
Сообщений: 47242

Мой профиль
In C++, one can use the next_permutation() function to generate all N! permutations very easily

2012 March Bronze : 2. Connect the Cows
Михаил Долинский

Темы: 1984
Сообщений: 47242

Мой профиль
we can use either a priority queue or a set (i.e., a balanced binary search tree)

... in an STL set, for example, we could use the lower_bound method ...

2013 November Silver 2. Crowded Cows
Михаил Долинский

Темы: 1984
Сообщений: 47242

Мой профиль
STL's upper_bound function nicely expresses the binary search.

2013 November Gold: 3. No Change
 
Индекс форума ->Олимпиадное программирование ->Обсуждение теории 1, 2
Time:0,064