-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLOJ-1113.cpp
More file actions
70 lines (65 loc) · 1.57 KB
/
LOJ-1113.cpp
File metadata and controls
70 lines (65 loc) · 1.57 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
#include<bits/stdc++.h>
using namespace std;
string url(string st){
return st.substr(6,st.length());
}
int main()
{
int t;
cin>>t;
getchar();
string commend;
for(int i=1; i<=t; i++)
{
stack<string> backward;
stack<string> forwards;
string current="http://www.lightoj.com/";
printf("Case %d:\n",i);
while(1)
{
getline(cin,commend);
if(commend=="QUIT")
{
break;
}
else if(commend=="BACK")
{
if(backward.empty()==true)
{
printf("Ignored\n");
}
else
{
forwards.push(current);
current=backward.top();
cout<<current<<"\n";
backward.pop();
}
}
else if(commend=="FORWARD")
{
if(forwards.empty()==true)
{
printf("Ignored\n");
}
else
{
backward.push(current);
current=forwards.top();
cout<<current<<"\n";
forwards.pop();
}
}
else
{
backward.push(current);
while(!forwards.empty()){
forwards.pop();
}
current=url(commend);
cout<<current<<"\n";
}
}
}
return 0;
}