logo AlgoBeat OnlineJudge
登录 注册

#214774. [ICPC 2025 Seoul R] Mex Culpa

内存限制:1024 MiB 时间限制:7000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Due to variations in the performance of the evaluation system, an additional 2 seconds of time limit is provided for this problem.


The mex (shorthand for minimum excluded value) of a sequence is the smallest non-negative integer that is not in the sequence. For example:

While the mex function has applications in combinatorial game theory, it is still a rather niche method for mapping a sequence to an integer. In the absence of a more organic problem, we have repurposed this concept to construct a task of a somewhat artificial nature. Sorry!

Write a program that, given two sequences of positive integers and , evaluates the following recurrence: for ,

输入格式

Your program is to read from standard input. The first line contains a single integer, (), representing the length of the sequences. The second line contains positive integers () representing the sequence . The third line contains positive integers (), representing the sequence .

输出格式

Your program is to write to standard output. Print exactly one line consisting of space-separated integers, denoting .

样例

样例输入 1

3
3 1 5
2 2 4

样例输出 1

0 1 1

样例输入 2

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

样例输出 2

0 1 1 2 1 2 2 3

样例输入 3

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

样例输出 3

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