QOJ.ac

QOJ

Límite de tiempo: 3 s Límite de memoria: 512 MB Puntuación total: 100

#16513. Li Xin Long

Estadísticas

Yuki keeps $n$ milk dragons at home. The $i$-th milk dragon has an attack power of $a_i$ and a defense power of $b_i$.

For the $i$-th milk dragon and the $j$-th milk dragon ($i \neq j$), if $a_i > b_j$, then the $i$-th milk dragon will attack the $j$-th milk dragon.

For each positive integer $k \le n$, you need to find the maximum number of milk dragons that can be selected from the first $k$ milk dragons such that no selected milk dragon attacks another selected milk dragon.

Input

  • The first line contains a positive integer $c$, representing the test case number. The sample satisfies $c=0$.
  • The second line contains a positive integer $n$.
  • The next $n$ lines each contain two positive integers $a_i, b_i$. It is guaranteed that all $a_i, b_i$ are distinct.

Output

Output $n$ lines, where the $i$-th line contains an integer representing the answer for $k=i$.

Examples

Input 1

0
3
1 6
3 2
5 4

Output 1

1
2
2

Note 1

  • For $k=1$, it is obvious that only the first milk dragon can be selected.
  • For $k=2$, the first two milk dragons can be selected.
  • For $k=3$, if all milk dragons are selected, the third milk dragon will attack the second milk dragon. Therefore, the maximum answer is $2$.

Input 2

See loong/loong2.in and loong/loong2.ans.

Output 2

See loong/loong2.in and loong/loong2.ans.

Input 3

See loong/loong3.in and loong/loong3.ans.

Output 3

See loong/loong3.in and loong/loong3.ans.

Input 4

See loong/loong4.in and loong/loong4.ans.

Output 4

See loong/loong4.in and loong/loong4.ans.

Input 5

See loong/loong5.in and loong/loong5.ans.

Output 5

See loong/loong5.in and loong/loong5.ans.

Input 6

See loong/loong6.in and loong/loong6.ans.

Output 6

See loong/loong6.in and loong/loong6.ans.

Input 7

See loong/loong7.in and loong/loong7.ans.

Output 7

See loong/loong7.in and loong/loong7.ans.

Constraints

For all test data, it is guaranteed that:

  • $1 \le n \le 10^6$;
  • $1 \le a_i, b_i \le 2n$, and all $a_i, b_i$ are distinct.
Test Case Number $n \le$ Special Property
$1$ $20$ None
$2 \sim 3$ $400$ None
$4$ $2000$ B
$5 \sim 6$ $2000$ None
$7$ $10^5$ B
$8$ $10^5$ C
$9 \sim 11$ $10^5$ None
$12$ $10^6$ A
$13$ $10^6$ B
$14$ $10^6$ C
$15 \sim 17$ $5 \times 10^5$ None
$18 \sim 20$ $10^6$ None
  • Special Property A: Guaranteed $a_i > b_i$.
  • Special Property B: Guaranteed $a_i < b_i$.
  • Special Property C: Guaranteed that no more than $100$ milk dragons satisfy $a_i > b_i$.

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.