report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Swap - MarisaOJ: Marisa Online Judge

Swap

Time limit: 1000 ms
Memory limit: 256 MB
For an array $A$ consisting of integers. Perform a sequence of $q$ operations to swap two elements in array $A$, resulting in a new array $B$. Given array $B$, restore the original array $A$. ### Input - The first line contains two integers $n,q$. - The second line contains $n$ integers $B_i$. - The next $q$ lines each contain two indices $x,y$ with $1 \le x,y \le n$, representing the operation to swap elements at positions $x$ and $y$ in array $A$. ### Output - Output $n$ integers representing the original array $A$. ### Constraints - $1 \le n,q, B_i \le 1000$. ### Example Input: ``` 5 4 1 2 3 4 5 1 2 2 4 3 1 1 5 ``` Output: ``` 4 3 5 2 1 ```
Array
Even elements
Smallest value
Average
Array reversal
Negative and positive
Consecutive differences
Largest value
Positive and negative
Dominant element
Second largest
Maximum product
Array rotation
Palindrome array
Circle
Insert
Positive subarray
Sorting
Similar Arrays
Unique
Unique 2
Frequent value
Most Frequent Value
Bitonic sequence
Swap
Topic
Basic
Rating 800
Solution (0) Solution