← 返回 pinterest 的题目列表Escape Room Leaderboard Participant Progress Tracking
类型:online_judge
pinterest
You are designing a leaderboard for an escape room center. There are n escape rooms and m participants. When the game starts, each participant is in one room and must solve the puzzle in that room before moving to the next room. Assume participants need to solve the puzzles independently. Please complete the following tasks:
Write a function to count how many participants are currently in a game.
If multiple participants are in the same room, note who finishes the puzzle first and moves to the next room.
Write a utility function that gets called each time a participant has progressed to the next room.
The function should accept the following inputs:
n: Number of rooms
m: Number of participants
proceed(participant_id): Called when a participant completes a puzzle and moves to the next room
Example:
n = 3
m = 2
R1 -> R2 -> R3
Participants progress in the order: P1 and then proceed(P2) is called while P1 is still in the first room
Expected output:
Two participants (P1, P2) solve in sequence, resulting in:
R1 -> R2 -> R3
R1 -> R2 -> R3
Example
Input
3
2
proceed 0
proceed 1