-
Notifications
You must be signed in to change notification settings - Fork 0
/
00230.cpp
47 lines (44 loc) · 1016 Bytes
/
00230.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
#include <bits/stdc++.h>
using namespace std;
int main()
{
freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
int x,y,z;
string s,s1,s2;
vector<pair<string,string> > arr;
vector<int> cmd;
while(getline(cin,s))
{
if(s == "END") break;
for(x = 1;s[x] != '"';x++);
s1 = s.substr(1,x - 1);
s2 = s.substr(x + 5,s.length());
arr.push_back(make_pair(s2,s1));
}
sort(arr.begin(),arr.end());
while(getline(cin,s))
{
if(s == "END") break;
if(s == "SHELVE")
{
sort(cmd.begin(),cmd.end());
for(vector<int>::iterator it = cmd.begin();it != cmd.end();it++)
{
if(*it == 0) cout << "Put \"" << arr[*it].second << " first" << endl;
else cout << "Put \"" << arr[*it].second << " after \"" << arr[*it - 1].second << endl;
}
cmd.clear();
cout << "END" << endl;
continue;
}
s1 = s.substr(0,x = s.find_first_of(" "));
if(s1 == "RETURN")
{
s2 = s.substr(x + 2,s.length() - 1);
for(y = 0;arr[y].second != s2;y++);
cmd.push_back(y);
}
}
return 0;
}