Unskippable subway game
InterviewTime limit1sMemory limit1024 MB
Given N stations where some are transfer stops, two players take turns advancing a subway model, and whoever places it at station N wins. Find the winner.
- Level
Medium5 of 10
- Topics
- Game theory, Array, Implementation
- Solved
- No attempts yet
Problem
Sehun and Mina want to play a game using a subway map and a subway model.
The map shows only one line, and stations are connected in a row along it. The stations are numbered from to in order. For every integer with , the station after station is station . So the station after is , the station after is , , and the station after is .
Every station except station and station is either a transfer station or a regular station. The starting station and the terminal station are always regular stations.
The rules of the game are as follows.
- Place the subway model at station .
- Sehun goes first, and the two players take turns.
- On each turn, a player moves the model to the next station one or more times, as many times as they like, and then passes the turn. However, if the model reaches a transfer station after a move, it cannot move any further. The turn passes to the opponent the moment the model arrives at a transfer station.
- The player who places the model at station during their own turn wins.
Both players always make the best possible choice to win. Given the information about the subway line, write a program that finds the winner.
Input
The first line contains the number of stations .
The second line contains integers separated by spaces, which describe each station. If station is a regular station, then . If it is a transfer station, then . and are always .
Output
On the first line, print mnx if Sehun wins, or alsdkffhgk if Mina wins.