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

Обсуждение задачи 1326. Крышки

Nikunj Banka How to use dynamic programming with bitmasking? [2] // Задача 1326. Крышки 12 окт 2013 21:21
Taking hints from the forum I am using dynamic programming with bitmasking. But I cannot understand how to memoize the results as the number of subproblems are very large. ie.
2^n * m
that is 2^20 * 120.
I am getting Memory limit exceeded. Is there a better way to define the states of the dp?
Yes. You have the matrix dp[120][2^20]. There is only transitions from n-th to (n+1)-th row of the matrix. So, you need to memorize only 2 rows (previous and current) instead 120.
Vedernikoff 'Goryinyich' Sergey (HSE: АОП) Re: How to use dynamic programming with bitmasking? // Задача 1326. Крышки 26 дек 2013 00:01
There is solution with only 2^n memory (not 2 arrays, but just one)