Problem

Source: 17th Durer Competition 2023 E+ P4

Tags: combinatorics



In a game, two players control an adventurer in a dungeon. The adventurer starts with $H{}$ hit points, an integer greater than one. The dungeon consists of several chambers. There are some passageways in the dungeon, each leading from a chamber to a chamber. These passageways are one-way, and a passageway may return to its starting chamber. Every chamber can be exited through at least one passageway. There are 5 types of chambers: Entrance: the adventurer starts here, no passageway comes in here; Hollow: nothing happens; Spike: the adventurer loses a hit point; Trap: the adventurer gets shot by an arrow; Catacomb: the adventurer loses hit points equal to the total number of times they have been hit by an arrow. The two players control the adventurer alternatively. At a turn, a player can move him through one passageway. A player loses if the adventurer’s hit points fall below zero due to their action (at 0 hit points, the character is alive). Construct a dungeon map, which has at most 20 chambers in total and exactly one entrance, with the following condition: the first player has a winning strategy if $H{}$ is a prime, and the second player has a winning strategy if $H{}$ is composite. Note: If the game doesn’t end after a finite number of moves, neither player wins.