Logo
(追記) (追記ここまで)

30448번 - Perfect Quadrants 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 1024 MB859820.000%

문제

Consider the plane and any point $(x, y)$ in the plane. Now, you draw two half-lines starting from point $(x, y),ドル one downwards vertically and the other leftwards horizontally. The (infinite) region below the horizontal half-line and to the left of the vertical half-line is called a quadrant, denoted by $Q(x, y)$. Note that the two half-lines of $Q(x, y)$ form its boundary, while its interior excludes the boundary. See below.

Let $L$ be a natural number and $S$ be the set of points $(x, y)$ in the plane with $x, y \in \{0,1,2, \dots , L\}$. So, $S$ consists of $(L + 1)^2$ points. For some $k ≥ 1,ドル you are given $k$ finite subsets $P_1, P_2, \dots , P_k \subseteq S$ of $S$ and $k$ nonnegative integers $c_1, c_2, \dots , c_k$. We say that a quadrant $Q$ is $(c_1, c_2, \dots , c_k)$-perfect when the following condition is satisfied for all $i = 1, 2, \dots , k$:

No points in $P_i$ lie on the boundary of $Q$ and $|P_i \cap Q| = c_i$.

Write a computer program that computes and prints out the number of points $(x, y) \in S$ such that $Q(x, y)$ is $(c_1, c_2, \dots , c_k)$-perfect.

입력

Your program is to read from standard input. The input starts with a line consisting of two integers, $L$ and $k$ (1ドル ≤ L ≤ 10^9,ドル 1ドル ≤ k ≤ 100,000円$). The second line of the input consists of $k$ nonnegative integers $c_1, c_2, \dots , c_k$ (0ドル ≤ c_1, c_2, \dots , c_k ≤ 1,000円,000円$). The third line consists of a single integer $N$ (1ドル ≤ N ≤ 1,000円,000円$), where $N$ denotes the total number of input points, that is, $N = |P_1| + |P_2| + \cdots + |P_k|$. In each of the following $N$ lines, three integers $x,ドル $y,ドル and $i$ (0ドル ≤ x, y ≤ L,ドル 1ドル ≤ i ≤ k$) are given, meaning that the point $(x, y)$ is a member of the set $P_i$. You can assume that no axis-parallel line passes through two of the $N$ input points.

출력

Your program is to write to standard output. Print exactly one line. The line should consist of a single integer, representing the number of points $(x, y) \in S$ such that $Q(x, y)$ is $(c_1, c_2, \dots , c_k)$-perfect.

제한

예제 입력 1

10 1
1
9
0 3 1
8 0 1
4 1 1
6 2 1
7 7 1
2 5 1
3 6 1
1 8 1
5 4 1

예제 출력 1

7

예제 입력 2

10 1
2
9
0 3 1
8 0 1
4 1 1
6 2 1
7 7 1
2 5 1
3 6 1
1 8 1
5 4 1

예제 출력 2

0

예제 입력 3

10 2
1 1
8
1 4 1
2 7 2
4 6 1
5 3 2
6 5 1
7 2 2
8 1 1
9 9 2

예제 출력 3

3

힌트

출처

ICPC > Regionals > Asia Pacific > Korea > Nationwide Internet Competition > Seoul Nationalwide Internet Competition 2023 F번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /