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

Обсуждение задачи 1501. Чувство прекрасного

Any idea?
Послано Olympic Bear 12 ноя 2006 01:33


Edited by author 12.11.2006 01:35
Re: Any idea?
Послано Piratek-(akaDK) 12 сен 2008 21:40
BFS
Re: Any idea?
Послано S.77 15 авг 2011 22:53
You can read the input into the status table which has a number 'x' inside the cell "[i][j]" if the difference in height between two piles (red and black) after you remove 'i' cards from the first pile and 'j' from the second one is 'x'.
For the first statement example, the table is: {{0,-1,0,1,0},{-1,-2,-1,0,-1},{-2,-3,-2,-1,-2},{-1,-2,-1,0,-1},{0,-1,0,1,0}} (you can view it using "Wolfram|Alpha" service).

Thus, you are to "move" over the table cells from the top left-hand one to the bottom right-hand one, but you can't visit cells with the values different from -1,0,1. Use DP with the diagonal process to draw the right way.
Re: Any idea?
Послано IgorKoval(from Pskov) 10 фев 2012 04:47
It help you. I don't post all code =)

int n;
vector<int> poker_log, I, II;
vector<vector<bool>> IsUs;

void f( int posI, int posII, int kol0, int kol1 ){
    if( abs(kol0-kol1)>1 ) return;
    if( !IsUs[posI][posII] ) IsUs[posI][posII] = true;
    else return;
    /* hush-hush secreted deleted code here*/
}

Just recursive function and bool vector IsUs[0..n][0..n] which answer on quastion "Was we in this state? Y/N"