問題一覧 > 通常問題

No.3709 Unknown Treasure

レベル : / AI推定難易度 : 900 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 1024 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 62
作問者 : UT0911 / テスター : sclara 👑 AngrySadEight Rino-program
お気に入りにしたユーザー ProblemId : 13610 / 自分の提出
問題文最終更新日: 2026-09-09 11:34:18
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 513 ゆーてぃーお誕生日コンテスト2026 (順位表) の他の問題:

Problem Statement

Yu-T is hunting for treasure on a grid of $H\times W$ cells.

Each cell is represented by coordinates $(r, c) (1 \leq r \leq H, 1 \leq c \leq W)$. Here, $r$ is the row number counted from the top, and $c$ is the column number counted from the left.

Yu-T has obtained $N$ pieces of information in advance. The $i$-th piece of information indicates that there is no treasure in the rectangular region specified by the upper-left cell $(r_{1,i}, c_{1,i})$ and the lower-right cell $(r_{2,i}, c_{2,i})$.

Based on all the information, find the number of cells that may contain treasure.

Constraints

  • All inputs are integers
  • $1 \leq H, W \leq 2000$
  • $1 \leq N \leq 2\times 10^5$
  • $1 \leq r_{1,i} \leq r_{2,i} \leq H$
  • $1 \leq c_{1,i} \leq c_{2,i} \leq W$

Input

$H$ $W$ $N$
$r_{1, 1}$ $c_{1, 1}$ $r_{2, 1}$ $c_{2, 1}$ 
$r_{1, 2}$ $c_{1, 2}$ $r_{2, 2}$ $c_{2, 2}$ 
$\vdots$
$r_{1, N}$ $c_{1, N}$ $r_{2, N}$ $c_{2, N}$ 

Output

Output the number of cells that may contain treasure.

Print a newline at the end.

Sample

Sample 1
Input
4 4 2
1 1 3 2
1 2 1 4
Output
8

Taking each piece of information into account gives the following. Here, x is a cell with no treasure, and . is a cell that may contain treasure.

....      xx..      xxxx
....  ->  xx..  ->  xx..
....      xx..      xx..
....      ....      ....

The number of cells that may contain treasure is $8$, so output 8.

Sample 2
Input
3 3 3
1 1 3 1
1 2 3 2
1 3 3 3
Output
0

Taking each piece of information into account gives the following.

...      x..      xx.      xxx
...  ->  x..  ->  xx.  ->  xxx
...      x..      xx.      xxx
Sample 3
Input
9 9 1
5 5 5 5
Output
80

Taking each piece of information into account gives the following.

.........    .........
.........    .........
.........    .........
.........    .........
......... -> ....#....
.........    .........
.........    .........
.........    .........
.........    .........

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。