11311 - Exclusively Edible

All about problems in Volume 113. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
Tomato
New poster
Posts: 5
Joined: Sun Oct 21, 2007 3:27 am

11311 - Exclusively Edible

Post by Tomato »

Trying to solve this problem using dp as follows:
d[n][m][pi][pj][player] - stores who is will win if we have field n x m, and the bad piece is at cell (pi,pj) and current turn to cut the cake is at the hensel (player = 0) and at gretel(player = 1). But I'm constantly getting WA. Could this approach be wrong?
Robert Gerbicz
Experienced poster
Posts: 196
Joined: Wed May 02, 2007 10:12 pm
Location: Hungary, Pest county, Halasztelek
Contact:

Re: 11311 - EXCLUSIVELY EDIBLE

Post by Robert Gerbicz »

Tomato wrote:Trying to solve this problem using dp as follows:
d[n][m][pi][pj][player] - stores who is will win if we have field n x m, and the bad piece is at cell (pi,pj) and current turn to cut the cake is at the hensel (player = 0) and at gretel(player = 1). But I'm constantly getting WA. Could this approach be wrong?
Is your program works for the sample input? I think it isn't very easy to avoid TLE by dp method. For example you can use:

Code: Select all

d[n][m][pi][pj][1]=1-d[n][m][pi][pj][0]
, so 4 dimensional array is also good.

If you see the times for this problem you'll observe that there are very fast times: 0.000 sec. There is an O(1) method for this problem, not dp.
Tomato
New poster
Posts: 5
Joined: Sun Oct 21, 2007 3:27 am

Post by Tomato »

yes, it works on sample. thanks for a hint. I'll think of O(1) solution.
roticv
Learning poster
Posts: 63
Joined: Sat Dec 11, 2004 9:28 am

Re: 11311 - Exclusively Editable

Post by roticv »

Think nim/nim sum.
aerofoil.kite
New poster
Posts: 12
Joined: Tue Dec 06, 2011 8:59 pm
Location: Bangladesh
Contact:

Re: 11311 - Exclusively Editable

Post by aerofoil.kite »

Code: Select all

**removed**
AC :)
Last edited by aerofoil.kite on Mon Aug 20, 2012 11:48 pm, edited 1 time in total.
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11311 - Exclusively Editable

Post by brianfry713 »

Input:

Code: Select all

1
48 47 5 6
AC output:

Code: Select all

Gretel
Check input and AC output for thousands of problems on uDebug!
Post Reply

Return to “Volume 113 (11300-11399)”