A game of consecutive piles
There are 6 piles of stones in a round configuration. In a single move, a player selects 3 consecutive piles, and removes some stones from 1 or more of these piles. (at least 1 stone must be removed from at least 1 pile).
A player loses if he can’t make any more moves in the current position. (equivalently, there do not exist any piles with non-zero amount of stones)
Given a starting position, output whether it is a winning or a losing position for the first player.
The game is a two players game and they play alternatively.
Note that even if a pile becomes empty, it still exists in the game as an empty pile. When selecting consecutive piles, one of them maybe an empty pile.
6 space separated integers on a line containing the initial number of stones in each pile. The last pile rounds over to the first.
“Winning“ (without quotes), if winning position
“Losing” (without quotes), if losing position
(take care of the Case)
0 ≤ Number of stones in each pile ≤ 10^6
Input: 1 0 0 0 0 0 Output: WinningInput: 1 0 0 1 0 0 Output: Losing
|Tags||admin2, game-theory, medium, wpc1, wpc1401|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions