luogu#P9283. [AGM 2023 资格赛] 棋子游戏

[AGM 2023 资格赛] 棋子游戏

Problem Description

Alice and Bob play a game on a 1×N1 \times N grid.

There are MM pieces placed on different cells, and the pieces have various colors.

In each turn, a player may choose one piece, and move this piece together with the consecutive pieces after it that have different colors (i.e., all pieces before the next piece of the same color) to the left by a positive distance. During the movement, they must not cross over or overlap the cell immediately in front of them. Alice moves first, and the player who cannot make a move loses.

Then there are QQ operations. Each operation is in one of the following forms:

1: Place a piece of color colcol at position pospos.

2: Remove the piece at position pospos.

After each operation, output who wins under the current position.

Input Format

The first line contains two integers N,M(1N109,1M105)N, M(1 \leq N \leq 10^9, 1 \leq M \leq 10^5).

The next MM lines each contain two integers pos(1posN)pos(1 \leq pos \leq N) and col(1col5)col(1 \leq col \leq 5), meaning there is initially a piece of color colcol at position pospos.

The next QQ lines each contain two or three integers. The first is opt(1opt2)opt(1 \leq opt \leq 2), indicating the operation type, followed by pos(1posN)pos(1 \leq pos \leq N). If opt=1opt = 1, then an additional integer col(1col5)col(1 \leq col \leq 5) is given.

Output Format

Output QQ lines. Each line should be either Alice or Bob.

30 6
3 1
6 2
11 3
14 2
17 3
27 1
4
1 24 1
2 24
1 23 1
1 29 2

Bob
Alice
Alice
Bob

Hint

Translated by ChatGPT 5