Responsive image

问题 1512 --访问网页

1512: 访问网页

时间限制: 1 Sec  内存限制: 128 MB
提交: 1  解决: 1
[提交][状态][讨论版][命题人:]

题目描述

Standard web browsers contain features to move backward and forward among the pages recently visited. One way to implement these features is to use two stacks to keep track of the pages that can be reached by moving backward and forward. In this problem, you are asked to implement this.
The following commands need to be supported:
BACK: Push the current page on the top of the forward stack. Pop the page from the top of the backward stack, making it the new current page. If the backward stack is empty, the command is ignored.
FORWARD: Push the current page on the top of the backward stack. Pop the page from the top of the forward stack, making it the new current page. If the forward stack is empty, the command is ignored.
VISIT : Push the current page on the top of the backward stack, and make the URL specified the new current page. The forward stack is emptied.
QUIT: Quit the browser.

Assume that the browser initially loads the web page at the URL http://acm.pdsu.edu.cn/
 

输入描述

Input is a sequence of commands. The command keywords BACK, FORWARD, VISIT, and QUIT are all in uppercase. URLs have no whitespace and have at most 70 characters. You may assume that no problem instance requires more than 100 elements in each stack at any time. The end of input is indicated by the QUIT command. 

输出描述

For each command other than QUIT, print the URL of the current page after the command is executed if the command is not ignored. Otherwise, print "Ignored". The output for each command should be printed on its own line. No output is produced for the QUIT command. 

样例输入

VISIT http://acm.pdsu.edu.cn/problemset.php
VISIT http://acm.pdsu.edu.cn/problem.php?id=1003
VISIT http://acm.pdsu.edu.cn/bbs/
VISIT http://acm.pdsu.edu.cn/bbs/read.php?tid=57&fid=2
BACK
BACK
BACK
BACK
FORWARD
FORWARD
BACK
VISIT http://jsjxy.pdsu.edu.cn/
BACK
BACK
BACK
BACK
FORWARD
FORWARD
BACK
QUIT

样例输出

http://acm.pdsu.edu.cn/problemset.php
http://acm.pdsu.edu.cn/problem.php?id=1003
http://acm.pdsu.edu.cn/bbs/
http://acm.pdsu.edu.cn/bbs/read.php?tid=57&fid=2
http://acm.pdsu.edu.cn/bbs/
http://acm.pdsu.edu.cn/problem.php?id=1003
http://acm.pdsu.edu.cn/problemset.php
http://acm.pdsu.edu.cn/
http://acm.pdsu.edu.cn/problemset.php
http://acm.pdsu.edu.cn/problem.php?id=1003
http://acm.pdsu.edu.cn/problemset.php
http://jsjxy.pdsu.edu.cn/
http://acm.pdsu.edu.cn/problemset.php
http://acm.pdsu.edu.cn/
Ignored
Ignored
http://acm.pdsu.edu.cn/problemset.php
http://jsjxy.pdsu.edu.cn/
http://acm.pdsu.edu.cn/problemset.php

提示

推荐使用C++ string类型  栈可以定义成string


来源

zj 

[提交][状态]
ACM算法攻关部
  • Anything about this OnlineJudge, Please Contact Administrator. Click add QQ

    OJ system based on HUSTOJ Project , UI based on Twitter Bootstrap

    Copyright 2016 ACM算法攻关部
    关于网站改版