-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUVa-13055.cpp
More file actions
43 lines (36 loc) · 1.04 KB
/
UVa-13055.cpp
File metadata and controls
43 lines (36 loc) · 1.04 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
#include <bits/stdc++.h> // here we have all the STL we need, including istringstream and ostringstream
#define ALL(x) x.begin(), x.end()
#define FAST std::cin.tie(0); ios::sync_with_stdio(false); std::cout.tie(0);
using namespace std;
#define min(a,b) (a < b) ? (a) : (b)
#define max(a,b) (a > b) ? (a) : (b)
#define vii vector<pair<int,int>>
int main() {
// first go, no comeback.
int n;
cin >> n;
stack<string> stacc;
string op;
queue<string> q;
string trash, name;
getchar();
while (n--) {
getline(cin, op);
if (op[0] == 'T') {
if (stacc.empty()) q.push("Not in a dream");
else q.push(stacc.top());
}
else if (op[0] == 'K') {
if (stacc.empty()) continue;
else stacc.pop();
}
// sleep (input not yet taken)
else {
istringstream iss (op);
iss >> trash >> name;
stacc.push(name);
}
}
while (!q.empty()) { cout << q.front() << endl; q.pop(); }
return 0;
}