-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path271.cpp
More file actions
78 lines (73 loc) · 1.7 KB
/
Copy path271.cpp
File metadata and controls
78 lines (73 loc) · 1.7 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//
// main.cpp
// sgu271
//
// Created by Silly on 14-3-26.
// Copyright (c) 2014年 Silly. All rights reserved.
//
#include <iostream>
#include <deque>
#include <vector>
using namespace std;
int n , m, k;
char ch;
string st;
int main(int argc, const char * argv[])
{
deque<string> c;
vector<string> v;
vector<string>::iterator vit;
deque<string>::iterator dit;
deque<string>::reverse_iterator rit;
int flag = 1;
cin >> n >> m >> k;
for (int i = 0; i < n; i++) {
cin >> st;
c.push_back(st);
}
while (c.size() > k) {
rit = c.rbegin();
v.push_back(*rit);
c.pop_back();
}
for (int i = 0; i < m; i++) {
cin >> st;
if (st[0] == 'A') {
string tmp;
tmp = "";
for (int i = 4; st[i] != ')'; i++) {
tmp += st[i];
}
if (!flag) {
c.push_back(tmp);
if (c.size() > k) {
dit = c.begin();
v.push_back(*dit);
c.pop_front();
}
} else {
c.push_front(tmp);
if (c.size() > k) {
rit = c.rbegin();
v.push_back(*rit);
c.pop_back();
}
}
} else {
flag ^= 1;
}
}
if (!flag) {
for (rit = c.rbegin(); rit != c.rend(); rit++) {
cout << *rit << endl;
}
} else {
for (dit = c.begin(); dit != c.end(); dit++) {
cout << *dit << endl;
}
}
for (vit = v.end()-1; vit >= v.begin(); vit--) {
cout << *vit << endl;
}
return 0;
}