#P1571. 眼红的 Medusa

    ID: 2366 远端评测题 1000ms 125MiB 尝试: 1 已通过: 1 显示难度普及− 上传者: 标签>模拟二分洛谷原创排序

眼红的 Medusa

Problem Description

Although Miss Medusa has arrived in Beijing and received the Science and Technology Innovation Award, she is still not satisfied. The reason is that she found many people also received the Science and Technology Innovation Award, and some of them even received another award — the Special Contribution Award. The more people receive both awards, the more envious Miss Medusa becomes. So she decides to count who received both awards to know how envious she is.

Input Format

The first line contains two integers n,mn, m, meaning there are nn people who received the Science and Technology Innovation Award and mm people who received the Special Contribution Award.

The second line contains nn positive integers, the IDs of the people who received the Science and Technology Innovation Award.

The third line contains mm positive integers, the IDs of the people who received the Special Contribution Award.

Output Format

Output one line: the IDs of the people who received both awards, in the same order as in the Science and Technology Innovation Award winners list.

4 3
2 15 6 8
8 9 2

2 8

Hint

For 60%60\% of the testdata, 0n,m10000 \leq n, m \leq 1000, and each award recipient’s ID is <2×109\lt 2 \times 10^9.

For 100%100\% of the testdata, 0n,m1050 \leq n, m \leq 10^5, and each award recipient’s ID is <2×109\lt 2 \times 10^9.

It is guaranteed that all numbers on the second line are pairwise distinct, and all numbers on the third line are pairwise distinct.

Translated by ChatGPT 5