Game (The 9th ACM Provincial Competition of Shandong Province in 2018)

g: meaning of the title:

Given n piles of stones, two players nim game, you are asked to remove at most d piles of stones in advance, and there are several ways to move the second player to win.

t <=5

n<=1000

d<=1000

ai<=1000 (number of stones per pile)

Ideas: As soon as nim's idea comes out, he immediately thinks that the XOR is 0. Therefore, the problem is transformed into, at most, remove d piles of stones, so that there are several solutions for the XOR of the remaining stones.

My workaround is memoized search. dp[i][j][k] Record status. Search from front to back, each pile of stones want or not, enumerate to the end of the last element and return the result, and remember the words. can solve this problem. (Be sure to enumerate to the end...)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325796560&siteId=291194637