7-2 队列应用(蓝桥杯)
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Queue<String> vip = new LinkedList<>();
Queue<String> putong = new LinkedList<>();
int m = sc.nextInt();
sc.nextLine();
while(m-->0){
String s = sc.nextLine();
String[] str = s.split(" ");
if(str[0].contains("IN")){
if(str[2].contains("N")){
putong.offer(str[1]);
}else{
vip.offer(str[1]);
}
}else{
if(str[1].contains("N")){
putong.poll();
}else{
vip.poll();
}
}
}
for(String s : vip){
System.out.println(s);
}
for(String s : putong){
System.out.println(s);
}
}
}