cswork / OA打开练习工作台

InstacartOA #1

Balloon Color Pairs

估计中等可在线判题

考点(AI 标注)原地数组模拟/实现

Positions are initially uncolored; each query colors a position with a given color (overwriting is allowed). After each query, count the pairs of adjacent positions that are both colored and have the same color.

输入格式

length,q≤200000, followed by q lines of a 0-based index and a positive color value.

输出格式

The count after each operation.

样例 1

输入:

5 4
0 1
1 1
2 1
1 3

输出:

0 1 2 0

样例 2

输入:

1 2
0 4
0 4

输出:

0 0

样例 3

输入:

3 3
0 2
2 2
1 2

输出:

0 0 2