-
Notifications
You must be signed in to change notification settings - Fork 0
/
Light-oj-1113.cpp
39 lines (31 loc) · 863 Bytes
/
Light-oj-1113.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
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
for(int tc = 1; tc <= t; ++tc) {
string cmd, url;
vector<string> v;
v.push_back("http://www.lightoj.com/");
int pos = 0;
cout << "Case " << tc << ":\n";
while(cin >> cmd, cmd != "QUIT") {
if(cmd == "VISIT") {
cin >> url;
v.resize(pos+1);
v.push_back(url);
cout << v[++pos] << '\n';
}
else if(cmd == "BACK") {
if(pos-1 < 0) cout << "Ignored\n";
else cout << v[--pos] << '\n';
}
else if(cmd == "FORWARD") {
if(pos+1 >= int(v.size())) cout << "Ignored\n";
else cout << v[++pos] << '\n';
}
}
}
return 0;
}