ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1284. Space Poker

How to solve it fast?
Posted by Yu Yuanming 29 Dec 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?
Posted by Yu Yuanming 29 Dec 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?
Posted by ahyangyi_newid 9 Jan 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?
Posted by Yuen Yoon Ming 10 Jan 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?
Posted by Burunduk1 27 Jan 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.
Posted by Yu Yuanming 27 Jan 2006 11:07
Re: How to solve it fast?
Posted by svr 21 Aug 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?
Posted by Глащенко Никита 27 Aug 2009 13:47
AC in 0.031 with complexity O(X!Y!*N^2) and some optimization O_o