QOJ.ac

QOJ

时间限制: 5 s 内存限制: 512 MB 总分: 100 可 Hack ✓

#4219. 곤충

统计

당신의 테라리움에는 $n$마리의 검은 개미가 있으며, $i$번째 검은 개미는 좌표 $(a_i, b_i)$에 살고 있습니다.

앞으로 $m$일 동안 매일 새로운 개미를 한 마리씩 테라리움에 추가합니다. 당신은 흰 개미만 구매하며, $i$번째로 구매하는 흰 개미는 좌표 $(x_i, y_i)$에 살게 됩니다.

매일 당신은 일부 곤충에게 먹이를 줍니다. 곤충에게 먹이를 주면 그날은 그 곤충이 배고프지 않습니다. $i$번째 흰 개미가 배고프고 $j$번째 검은 개미가 배고픈 상태에서 $x_i \ge a_j$이고 $y_i \ge b_j$라면, 두 개미는 싸우게 됩니다. 매일 싸움이 일어나지 않도록 먹이를 주어야 하는 최소 개미 수를 구하십시오.

입력

첫 번째 줄에는 테라리움에 있는 검은 개미의 수 $n$ ($1 \le n \le 100\,000$)이 주어집니다.

다음 $n$개의 줄에는 검은 개미에 대한 정보가 주어집니다. 각 줄에는 $i$번째 검은 개미의 좌표를 나타내는 두 정수 $a_i, b_i$ ($0 \le a_i, b_i \le 100\,000$)가 포함되어 있습니다.

다음 줄에는 새로운 흰 개미를 구매할 날짜 수 $m$ ($1 \le m \le 100\,000$)이 주어집니다.

다음 $m$개의 줄에는 구매하는 순서대로 흰 개미에 대한 정보가 주어집니다. 각 줄에는 $i$번째 흰 개미의 좌표를 나타내는 두 정수 $x_i, y_i$ ($0 \le x_i, y_i \le 100\,000$)가 포함되어 있습니다.

서로 다른 개미가 같은 좌표에 살 수 있음에 유의하십시오.

출력

$m$개의 정수를 출력하십시오. $i$번째 정수는 검은 개미 $1, 2, \dots, n$과 흰 개미 $1, 2, \dots, i$ 사이의 싸움을 피하기 위해 먹이를 주어야 하는 최소 개미 수입니다.

예제

입력 1

3
0 0
1 1
2 2
4
0 0
1 1
0 0
3 3

출력 1

1
2
2
3

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1013EditorialOpen题解Qiuly2026-02-14 01:41:57View

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.