AtCoder Regular Contest 130
B
Colorful Lines
AtCoder
⌀ 576
原题
← AC →
翻译中…

Problem Statement

翻译中…

We have an $H\times W$ grid. Initially, the squares are unpainted.

翻译中…

You will paint these squares. There are $C$ colors available, numbered $1, 2, \ldots, C$.

翻译中…

The painting process will be given as $Q$ queries. The $i$-th query contains integers $t_i, n_i, c_i$, which represents the following action.

翻译中…
  • If $t_i = 1$: paint all squares in the $n_i$-th row with Color $c_i$.
  • If $t_i = 2$: paint all squares in the $n_i$-th column with Color $c_i$.
翻译中…

Painting a square with Color $c$ makes the color of that square Color $c$, regardless of its previous state.

翻译中…

Find the number of squares painted in each of Color $1, 2, \ldots, C$ after the whole process.

翻译中…

Constraints

翻译中…
  • $2\leq H\leq 10^9$
  • $2\leq W\leq 10^9$
  • $1\leq C\leq 3\times 10^5$
  • $1\leq Q\leq 3\times 10^5$
  • $t_i\in \{1,2\}$
  • $1\leq n_i\leq H$ if $t_i = 1$
  • $1\leq n_i\leq W$ if $t_i = 2$
  • $1\leq c_i\leq C$
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

H W C Q
t_1 n_1 c_1
\vdots
t_Q n_Q c_Q

翻译中…

Output

翻译中…

Print a line containing the numbers of squares painted in Color $1, 2, \ldots, C$, with spaces in between.

翻译中…

样例

Input #1
4 5 6 5
1 1 6
1 3 3
2 2 4
2 4 2
1 1 2
Output #1
0 8 3 3 0 0
The process changes the colors of the squares as follows. Here, `.` denotes an unpainted square.
Input #2
1000000000 1000000000 3 5
1 1 2
1 2 2
1 3 2
1 4 2
1 5 2
Output #2
0 5000000000 0
题目信息
题号
arc130_b
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。