QOJ.ac

QOJ

Límite de tiempo: 60 s Límite de memoria: 64 MB Puntuación total: 20

#23755. 問題 5

Estadísticas

問題文

平面に長方形のシートが何枚か置かれている.これらのシートで覆われている部分の面積や周長を求めるプログラムを作成せよ.

ただし,平面を座標平面とみなしたとき,シートの配置は次の条件 $(1)$, $(2)$ を満たすものとする.

  • $(1)$ 各シートの長方形の $4$ 頂点の $x, y$ 座標は全て $0$ 以上 $10000$ 以下の整数であり,長方形の各辺は $x$ 軸,または $y$ 軸に平行である.
  • $(2)$ シートの枚数は高々 $10000$ 枚以下である.

入力ファイルのファイル名は input.txt である.input.txt の $1$ 行目に長方形の個数 $n$ と問題の種類を表す整数 $r$ が空白で区切って書かれている.$2$ 行目以降の各行には,各シートの左下頂点座標 $(x_1, y_1)$ と右上頂点座標 $(x_2, y_2)$ の座標値が $x_1, y_1, x_2, y_2$ の順で空白で区切って書いてある.

出力ファイルのファイル名は output.txt である.output.txt には $r = 1$ のとき $1$ 行目に面積を,$r = 2$ のとき $1$ 行目に面積,$2$ 行目に周囲の長さを出力する.いずれの場合も最後に改行を入れること.

また,テストデータの $40\%$ では長方形の頂点の座標が $0$ 以上 $100$ 以下で,そのうちの $1/2$ では面積だけを求める問題である.さらに,全体の $1/2$ は面積だけを求める問題である.

入出力例 1

入力例 1

5 1
0 0 3 2
1 1 2 5
0 4 6 5
3 3 5 6
5 0 7 6

出力例 1

29

入出力例 2

入力例 2

5 2
0 0 3 2
1 1 2 5
0 4 6 5
3 3 5 6
5 0 7 6

出力例 2

29
38

入出力例 3

入力例 3

2 2
0 0 8 9
0 0 9 8

出力例 3

80
36

入出力例 4

入力例 4

3 2
2 2 8 8
3 0 4 9
5 0 7 9

出力例 4

45
36

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.