练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 paper cups upside down on the table, numbered from to . Each cup has a number written inside.
Xiaohua first tells Xiaoming the numbers on each cup, then quickly performs swap operations:
Choose two cups and , and swap their positions. (If and are the same, no swap occurs)
Now Xiaohua wants you to answer: what are the numbers on the cups after operations?
Input Format
The first line contains two numbers and , representing the number of cups and operations ();
The second line contains numbers, representing the numbers inside each cup;
The next lines each contain two numbers and , indicating which cups to swap.
Output Format
Output one line containing 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 31 3 5 20 11 4 7 6
20230913C班作业(1)
- Status
- Done
- Problem
- 6
- Open Since
- 2025-9-13 0:00
- Deadline
- 2025-9-21 23:59
- Extension
- 24 hour(s)