QOJ.ac

QOJ

時間限制: 4 s 記憶體限制: 4096 MB 總分: 100

#4345. hpmo

统计

Given $n$ distinct points $(x_i, y_i)$ and $m$ sets $S_j = \{(x_i, y_i) \mid A_j x_i + B_j y_i + C_j > 0\}$, you need to find a permutation $p_1, p_2, \dots, p_m$ of $1, 2, \dots, m$ such that $|S_{p_1}| + \sum_{i=2}^m |S_{p_i} \oplus S_{p_{i-1}}| \le M$, where $M$ is a given constant and $A \oplus B$ denotes the symmetric difference $(A \cup B) - (A \cap B)$.

Input

The first line contains two integers $n$ and $m$.

The next $n$ lines each contain two integers representing $x_i$ and $y_i$.

The next $m$ lines each contain three integers representing $A_j$, $B_j$, and $C_j$.

Output

Output $m$ lines, representing $p_1, p_2, \dots, p_m$ in order.

Examples

Input 1

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

Output 1

1
2
3
4
5

Examples 2~3

See the provided files.

Subtasks

Idea: nzhtl1477, Solution: ccz181078, Code: ccz181078, Data: ccz181078

Note: Bundled testing is used.

For $20\%$ of the data, $1 \le n \le 10^4$ and $1 \le m \le 10^4$.

For another $30\%$ of the data, $x_i = y_i$ or $x_i = -y_i$.

For $100\%$ of the data, $1 \le n \le 10^5$, $1 \le m \le 2 \times 10^5$, $-10^9 \le A, B, C, x_i, y_i \le 10^9$, $M = 1.8 \times 10^8$, and all inputs are integers.

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.