QOJ.ac

QOJ

実行時間制限: 5 s メモリ制限: 512 MB 満点: 100 ハック可能 ✓

#4219. 昆虫

統計

テラリウムには $n$ 匹の黒いアリがおり、$i$ 番目の黒いアリは座標 $(a_i, b_i)$ に住んでいます。

今後 $m$ 日間、毎日新しいアリを1匹ずつ購入します。購入するのは白いアリのみで、$i$ 番目に購入する白いアリは座標 $(x_i, y_i)$ に住みます。

毎日、飼育している昆虫のうち何匹かに餌を与えます。昆虫に餌を与えると、その日はその昆虫は空腹になりません。$i$ 番目の白いアリが空腹で、かつ $j$ 番目の黒いアリが空腹であり、さらに $x_i \ge a_j$ かつ $y_i \ge b_j$ である場合、それらは喧嘩をします。

毎日について、喧嘩が起こらないようにするために餌を与える必要のある最小のアリの数を求めてください。

入力

1行目には、テラリウムにいる黒いアリの数 $n$ ($1 \le n \le 100\,000$) が与えられます。

続く $n$ 行には、黒いアリの情報が与えられます。$i$ 番目の行には、2つの整数 $a_i, b_i$ ($0 \le a_i, b_i \le 100\,000$) が含まれます。

次の行には、白いアリを購入する日数 $m$ ($1 \le m \le 100\,000$) が与えられます。

続く $m$ 行には、購入する順に白いアリの情報が与えられます。$i$ 番目の行には、2つの整数 $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.