第十三届JAVAB组决赛——4.左移右移
import java.io.*;
import java.util.*;
public class Main{
public static BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
public static PrintWriter stdOut = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
public static final int N = 200010;
public static int[][] a = new int[N][2];
public static int n, m;
public static void main(String[] args) throws IOException{
String[] sp = stdIn.readLine().split(" ");
n = Integer.parseInt(sp[0]); m = Integer.parseInt(sp[1]);
for(int i = 0; i < n; i++) {
a[i][0] = a[i][1] = i + 1;
}
int min = 1; int max = n;
while(m-- > 0) {
sp = stdIn.readLine().split(" ");
char op = sp[0].charAt(0);
int x = Integer.parseInt(sp[1]);
a[x-1][1] = (op == 'L' ? --min : ++max);
}
//按照附着数排序
Arrays.sort(a, 0, n, new Comparator<int[]>() {
public int compare(int[] o1, int[] o2) {
return Integer.compare(o1[1], o2[1]);
}
});
for(int i = 0; i < n; i++)
stdOut.print(a[i][0] + " ");
stdOut.flush();
}
}