-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10811.java
More file actions
31 lines (28 loc) · 952 Bytes
/
10811.java
File metadata and controls
31 lines (28 loc) · 952 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
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer 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 k=1;k<=N;k++){
basket[k]=k;
}
for(int k=0;k<M;k++){
st = new StringTokenizer(br.readLine());
int i = Integer.parseInt(st.nextToken());
int j = Integer.parseInt(st.nextToken());
while (i<j){
int temp = basket[i];
basket[i++] = basket[j];
basket[j--] = temp;
}
}
for(int k=1;k<=N;k++){
System.out.print(basket[k] + " ");
}
br.close();
}
}