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

Обсуждение задачи 1284. Космический покер

How to solve it fast?
Послано Yu Yuanming 29 дек 2005 12:20
My algo is O(C(n,n/2)*n),where C(n, m)=n!/(m!(n-m)!),it takes 0.375sec,a bit slow:(

I just want to know how to solve it less than 0.1sec?
Do they use search?

Edited by author 29.12.2005 12:40
Re: How to solve it fast?
Послано Yu Yuanming 29 дек 2005 12:34
I have found another two algo:
1.Use full search,O(2^n*n);
2.Use search + greedy,O(((m/2)!*n)^2).
But they are not faster than the one above:(
Re: How to solve it fast?
Послано ahyangyi_newid 9 янв 2006 13:17
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOYEEEEEEEEEEEEEAAAAAAAH!
I got AC in 0.015 sec after times of submitting~
Using only 134KB memoru~

Note that m (Number of suits) <=10. And we can check how many steps a state can be arrival in O(n^2). Also, you should do some pre-calculating instead of repeat the same thing for many times.

Edited by author 09.01.2006 13:21
Re: How to solve it fast?
Послано Yuen Yoon Ming 10 янв 2006 21:14
Thank you for your reply.

Yes, we can calculate how many steps a state can be arrival in O(n^2).
I think your algo may look like the one that use search + greedy,O(((m/2)!*n)^2).
But what is the exact time of your algo,could you tell me?
Re: How to solve it fast?
Послано Burunduk1 27 янв 2006 03:22
My solution also works in O(C(n,n/2)*n)
But it gets AC in 0.062
Careful and fast implementation, nothing more.
I see, thx.
Послано Yu Yuanming 27 янв 2006 11:07
Re: How to solve it fast?
Послано svr 21 авг 2007 16:25
Friend!
You keep in your secret the main tool:
O(n^2) calculuce number of steps for arraving to
[a1,a2,...,an] from[1,2,....,n].
This is brilliant theorem anf I spent 4 days
before created it myself.
answer=N-length of most long increasing subsequence.
Re: How to solve it fast?
Послано Глащенко Никита 27 авг 2009 13:47
AC in 0.031 with complexity O(X!Y!*N^2) and some optimization O_o