-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10813.java
More file actions
57 lines (48 loc) · 1.42 KB
/
10813.java
File metadata and controls
57 lines (48 loc) · 1.42 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package algo;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;
public class Main {
private static int N;
private static int M;
private static int[] arr;
public static void main(String[] args) throws IOException {
InputClass.input();
InputClass.close();
}
static class InputClass {
public static final BufferedReader BR = new BufferedReader(new InputStreamReader(System.in));
public static final BufferedWriter BW = new BufferedWriter(new OutputStreamWriter(System.out));
private static StringTokenizer st = null;
public static void input() throws IOException {
st = getStringTokenizer();
N = Integer.parseInt(st.nextToken());
M = Integer.parseInt(st.nextToken());
arr = new int[N+1];
for(int i=1; i<=N; i++) {
arr[i] = i;
}
for(int i=0; i<M; i++) {
st = getStringTokenizer();
int a = Integer.parseInt(st.nextToken());
int b = Integer.parseInt(st.nextToken());
int tmp = arr[a];
arr[a] = arr[b];
arr[b] = tmp;
}
for(int i=1; i<=N; i++) {
BW.write(String.valueOf(arr[i]) + " ");
}
}
public static void close() throws IOException {
BR.close();
BW.close();
}
public static StringTokenizer getStringTokenizer() throws IOException {
return new StringTokenizer(InputClass.BR.readLine(), " ");
}
}
}