knightnemo commited on
Commit
df8197e
·
verified ·
1 Parent(s): 96fa7d5

Upload code_segments/segment_135.txt with huggingface_hub

Browse files
Files changed (1) hide show
  1. code_segments/segment_135.txt +22 -0
code_segments/segment_135.txt ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ You are given a matrix, consisting of $n$ rows and $m$ columns.
2
+
3
+ You can perform two types of actions on it:
4
+
5
+ * paint the entire column in blue; * paint the entire row in red.
6
+
7
+ Note that you cannot choose which color to paint the row or column.
8
+
9
+ In one second, you can perform either one action or multiple actions at the same time. If you perform one action, it will be free. If you perform $k > 1$ actions at the same time, it will cost $k^2$ coins. When multiple actions are performed at the same time, for each cell affected by actions of both types, the color can be chosen independently.
10
+
11
+ You are asked to process $q$ queries. Before each query, all cells become colorless. Initially, there are no restrictions on the color of any cells. In the $i$-th query, a restriction of the following form is added:
12
+
13
+ * $x_i~y_i~c_i$ — the cell in row $x_i$ in column $y_i$ should be painted in color $c_i$.
14
+
15
+ Thus, after $i$ queries, there are $i$ restrictions on the required colors of the matrix cells. After each query, output the minimum cost of painting the matrix according to the restrictions.
16
+
17
+ The first line contains three integers $n, m$ and $q$ ($1 \le n, m, q \le 2 \cdot 10^5$) — the size of the matrix and the number of queries.
18
+
19
+ In the $i$-th of the next $q$ lines, two integers $x_i, y_i$ and a character $c_i$ ($1 \le x_i \le n$; $1 \le y_i \le m$; $c_i \in$ {'R', 'B'}, where 'R' means red, and 'B' means blue) — description of the $i$-th restriction. The cells in all queries are pairwise distinct.
20
+
21
+ Print $q$ integers — after each query, output the minimum cost of painting the matrix according to the restrictions.
22
+