-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ10813.java
More file actions
34 lines (28 loc) · 1017 Bytes
/
Copy pathJ10813.java
File metadata and controls
34 lines (28 loc) · 1017 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package TIL;
import java.io.*;
import java.util.*;
public class J10813 {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
st = new StringTokenizer(br.readLine());
int N = Integer.parseInt(st.nextToken());
int M = Integer.parseInt(st.nextToken());
int[] basket = new int[N + 1];
for (int i = 1; i <= N; i++) basket[i] = i;
for (int k = 0; k < M; k++) {
st = new StringTokenizer(br.readLine());
int i = Integer.parseInt(st.nextToken());
int j = Integer.parseInt(st.nextToken());
int tmp = basket[i];
basket[i] = basket[j];
basket[j] = tmp;
}
StringBuilder sb = new StringBuilder();
for (int i = 1; i <= N; i++) {
if (i > 1) sb.append(' ');
sb.append(basket[i]);
}
System.out.println(sb.toString());
}
}