-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlateTOI1.cpp
51 lines (45 loc) · 997 Bytes
/
PlateTOI1.cpp
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
#include <bits/stdc++.h>
using namespace std;
int a[10100];
int q[1010];
int fr, en;
int main(){
int n,m,c,s,i,k;
char opr;
scanf("%d %d", &n , &m);
while(m--){
scanf("%d %d", &c, &s);
a[s] = c;
}
while(1){
scanf(" %c", &opr);
if(opr == 'X'){
printf("0\n");
return 0;
}
if(opr == 'E'){
scanf("%d", &n);
k = en;
for(i = en-1 ; i >= fr ; i--){
if(a[n] == a[q[i]]){
k = i+1;
break;
}
}
for(i = en-1 ; i >= k ; i--){
q[i+1] = q[i];
}
q[k] = n;
en++;
}
if(opr == 'D'){
if(fr == en){
printf("empty\n");
}
else{
printf("%d\n", q[fr++]);
}
}
}
return 0;
}