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?
11311 - Exclusively Edible
Moderator: Board moderators
-
- Experienced poster
- Posts: 196
- Joined: Wed May 02, 2007 10:12 pm
- Location: Hungary, Pest county, Halasztelek
- Contact:
Re: 11311 - EXCLUSIVELY EDIBLE
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: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?
Code: Select all
d[n][m][pi][pj][1]=1-d[n][m][pi][pj][0]
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.
Re: 11311 - Exclusively Editable
Think nim/nim sum.
-
- New poster
- Posts: 12
- Joined: Tue Dec 06, 2011 8:59 pm
- Location: Bangladesh
- Contact:
Re: 11311 - Exclusively Editable
Code: Select all
**removed**

Last edited by aerofoil.kite on Mon Aug 20, 2012 11:48 pm, edited 1 time in total.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11311 - Exclusively Editable
Input:
AC output:
Code: Select all
1
48 47 5 6
Code: Select all
Gretel
Check input and AC output for thousands of problems on uDebug!