C. 练51.3 纸杯猜数

    Type: Default 1000ms 256MiB

练51.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

You and Xiaohua are playing a number guessing game with paper cups.
Xiaohua has placed nn paper cups upside down on the table, numbered from 11 to nn. Each cup has a number written inside.
Xiaohua first tells Xiaoming the numbers on each cup, then quickly performs mm swap operations:
Choose two cups uu and vv, and swap their positions. (If uu and vv are the same, no swap occurs)
Now Xiaohua wants you to answer: what are the numbers on the cups after mm operations?

Input Format

The first line contains two numbers nn and mm, representing the number of cups and operations (1n,m500001≤n,m≤50000);
The second line contains nn numbers, representing the numbers inside each cup;
The next mm lines each contain two numbers uu and vv, indicating which cups to swap.

Output Format

Output one line containing nn numbers, representing the numbers inside each cup after all swaps, separated by spaces.

Sample

8 3
1 4 7 20 5 3 11 6
3 7
2 6
5 3
1 3 5 20 11 4 7 6

20230913C班作业(1)

Not Claimed
Status
Done
Problem
6
Open Since
2025-9-13 0:00
Deadline
2025-9-21 23:59
Extension
24 hour(s)