F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Nonsense Time

Time Limit: 14000/14000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 1878    Accepted Submission(s): 642


Problem Description
You a given a permutation $p_1,p_2,\dots,p_n$ of size $n$. Initially, all elements in $p$ are frozen. There will be $n$ stages that these elements will become available one by one. On stage $i$, the element $p_{k_i}$ will become available.

For each $i$, find the longest increasing subsequence among available elements after the first $i$ stages.
 

Input
The first line of the input contains an integer $T(1\leq T\leq 3)$, denoting the number of test cases.

In each test case, there is one integer $n(1\leq n\leq 50000)$ in the first line, denoting the size of permutation.

In the second line, there are $n$ distinct integers $p_1,p_2,...,p_n(1\leq p_i\leq n)$, denoting the permutation.

In the third line, there are $n$ distinct integers $k_1,k_2,...,k_n(1\leq k_i\leq n)$, describing each stage.

It is guaranteed that $p_1,p_2,...,p_n$ and $k_1,k_2,...,k_n$ are generated randomly.
 

Output
For each test case, print a single line containing $n$ integers, where the $i$-th integer denotes the length of the longest increasing subsequence among available elements after the first $i$ stages.
 

Sample Input
1 5 2 5 3 1 4 1 4 5 3 2
 

Sample Output
1 1 2 3 3
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 03:22:29, Gzip enabled