-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOJ18115.cpp
More file actions
46 lines (43 loc) · 846 Bytes
/
BOJ18115.cpp
File metadata and controls
46 lines (43 loc) · 846 Bytes
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
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
using namespace std;
int n,op;
vector<int> ops;
deque<int> dq;
int main(){
cin>> n;
for(int i=1;i<=n;i++)
{
cin>>op;
ops.push_back(op);
}
for(int i=1;i<=n;i++)
{
switch (ops.back())
{
case 1:{
dq.push_back(i);
break;
}
case 2:{
int tp=dq.back();
dq.pop_back();
dq.push_back(i);
dq.push_back(tp);
break;
}
case 3:{
dq.push_front(i);
break;
}
}
ops.pop_back();
}
while(!dq.empty()){
cout<<dq.back()<<' ';
dq.pop_back();
}
}