Problem 3018 --Nonsense Time

3018: Nonsense Time

"
Time Limit $14$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $3$ 正确数量 $3$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
You a given a permutation p1,p2,…,pnp1,p2,…,pn of size nn. Initially, all elements in pp are frozen. There will be nn stages that these elements will become available one by one. On stage ii, the element pkipki will become available. 

For each ii, find the longest increasing subsequence among available elements after the first ii stages.
The first line of the input contains an integer T(1≤T≤3)T(1≤T≤3), denoting the number of test cases. 

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

In the second line, there are nn distinct integers p1,p2,...,pn(1≤pi≤n)p1,p2,...,pn(1≤pi≤n), denoting the permutation. 

In the third line, there are nn distinct integers k1,k2,...,kn(1≤ki≤n)k1,k2,...,kn(1≤ki≤n), describing each stage. 

It is guaranteed that p1,p2,...,pnp1,p2,...,pn and k1,k2,...,knk1,k2,...,kn are generated randomly.
For each test case, print a single line containing nn integers, where the ii-th integer denotes the length of the longest increasing subsequence among available elements after the first ii stages.
1
5
2 5 3 1 4
1 4 5 3 2
1 1 2 3 3

推荐代码 查看3018 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$2269 $ms] intLSY 481266 2019-10-09 21:58:44
内存最少[$4072 $KB] 淡意的温柔 590725 2020-06-05 09:11:19
第一AC intLSY 481266 2019-10-09 21:58:44
第一挑战 intLSY 481266 2019-10-09 21:58:44

赛题来源/所属竞赛 2019 Multi-University Training Contest 6 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛