-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1113 - Discover the Web.cpp
61 lines (54 loc) · 1.26 KB
/
1113 - Discover the Web.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <bits/stdc++.h>
using namespace std;
int main()
{
int tc, cn=0;
string s;
stack <string> fd, bd;
cin >> tc;
while(tc--)
{
while(!fd.empty())
fd.pop();
while(!bd.empty())
bd.pop();
fd.push("http://www.lightoj.com/");
printf("Case %d:\n",++cn);
while(1)
{
cin >> s;
if(s == "QUIT") break;
else if(s == "VISIT")
{
cin >> s;
fd.push(s);
while(!bd.empty())
bd.pop();
cout << fd.top() <<endl;
}
else if(s == "BACK")
{
if(fd.size()==1)
{
cout <<"Ignored"<<endl;
continue;
}
bd.push(fd.top());
fd.pop();
cout << fd.top() <<endl;
}
else if(s == "FORWARD")
{
if(bd.size()==0)
{
cout <<"Ignored"<<endl;
continue;
}
cout << bd.top() <<endl;
fd.push(bd.top());
bd.pop();
}
}
}
return 0;
}