D. 练61.3 文体两开花

    Type: Default 1000ms 64MiB

练61.3 文体两开花

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Description

The school is holding an award ceremony where nn students received the Literature Excellence Award and mm students received the Sports Excellence Award. Given the student IDs of both award winners, where each student has a unique ID, please help count the list of students who received both awards (achieved excellence in both literature and sports).

Input Format

First line contains two integers nn and mm (1n,m1051 \le n, m \le 10^5), representing the number of Literature Excellence Award winners and Sports Excellence Award winners respectively.
Second line contains nn distinct integers, representing the IDs of students who won the Literature Excellence Award.
Third line contains mm distinct integers, representing the IDs of students who won the Sports Excellence Award.
All IDs are positive integers not exceeding 10910^9.

Output Format

Output one line containing space-separated integers representing the IDs of students who won both awards, in the order they appear in the Literature Excellence Award list.

Sample

4 4
5 1 7 3
2 3 4 1
1 3

20250920C班作业(2)

Not Claimed
Status
Done
Problem
4
Open Since
2025-9-20 0:00
Deadline
2025-10-11 23:59
Extension
24 hour(s)