This page is still under construction.

Parts of this page are still being built. What you see may change.

Swap Balls

Time limit1sMemory limit256 MB

Summary
Swap the balls in the given basket pairs M times and print the final ball in each of the N baskets.
Level

Easy1 of 10

Topics
Simulation, Array
Solved
No attempts yet

Problem

Swap balls in baskets according to the given operations.

Input

N, M, and M swap pairs.

Output

Print the ball number in each basket.

Examples1

  1. Example 1

    Input
    5 4
    1 2
    3 4
    1 4
    2 2
    
    Expected output
    3 1 4 2 5