POJ 1028题目描述

Description

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://www.acm.org/

Input

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.

Output

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.

Sample Input

VISIT http://acm.ashland.edu/
VISIT http://acm.baylor.edu/acmicpc/
BACK
BACK
BACK
FORWARD
VISIT http://www.ibm.com/
BACK
BACK
FORWARD
FORWARD
FORWARD
QUIT

Sample Output

http://acm.ashland.edu/
http://acm.baylor.edu/acmicpc/
http://acm.ashland.edu/
http://www.acm.org/
Ignored
http://acm.ashland.edu/
http://www.ibm.com/
http://acm.ashland.edu/
http://www.acm.org/
http://acm.ashland.edu/
http://www.ibm.com/
Ignored
时间: 2024-10-23 06:18:39

POJ 1028题目描述的相关文章

POJ 1035题目描述

Description You, as a member of a development team for a new spell checking program, are to write a module that will check the correctness of given words using a known dictionary of all correct words in all their forms. If the word is absent in the d

POJ 1028 Web Navigation 题解

考查代码能力的题目.也可以说是算法水题,呵呵. 推荐新手练习代码能力. 要增加难度就使用纯C实现一下stack,那么就有点难度了,可以使用数组模拟环形栈.做多了,我就直接使用STL了. #include <stdio.h> #include <iostream> #include <stack> #include <string> using namespace std; int main() { stack<string> forward; s

poj 动态规划题目列表及总结

此文转载别人,希望自己能够做完这些题目! 1.POJ动态规划题目列表 容易:1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1208, 1276,1322, 1414, 1456, 1458, 1609, 1644, 1664, 1690, 1699, 1740(博弈),1742, 1887, 1926(马尔科夫矩阵,求平衡), 1936, 1952, 1953, 1958, 1959, 1962, 1975,

poj 最短路径题目总会

求最短路基本的算法:1>Dijkstra算法2>Bellman-Ford算法3>Floyd算法4>Floyd-Warshall算法5>Johnson算法6>A*算法题目: 1.poj1062 昂贵的聘礼(中等) 此题是个经典题目:用Dijkstra即可:但是其中的等级处理需要一定的技巧: 要理解好那个等级制度:这个处理好,基本就是裸体Dijkstra: 2 poj1125 Stockbroker Grapevine(基本) 这个是简单Floyd,需要求出的是每对顶点之间

【POJ 1028】模拟浏览器

本题要求模拟浏览器的前进.后退等操作. 用两个栈实现,一个控制前进,一个控制后退. 在前进与后退操作中,从一个栈中弹出栈顶元素,压入另一个栈中. 当打开一个新网页时,将前进栈清空. 代码如下: #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <cstdlib> #include

poj 1028

他就是个栈,栈就随便写了,贴代码 #include <iostream> #include <stack> #include <string> using namespace std; int main(){ stack<string> stack1,stack2; string str,s1,s2; str="http://www.acm.org/"; stack1.push(str); while(cin>>s1){ if

10月日常练习1题目描述

问题1. 最大公约数和最小公倍数问题 题目描述 输入2个正整数 \(x0, y0 (2 \le x0 \lt 100000, 2 \le y0 \le 1000000)\) ,求出满足下列条件的 P,Q 的个数. 条件: P,Q是正整数 要求 P,Q 以 x0 为最大公约数,以 y0 为最小公倍数. 试求:满足条件的所有可能的2个正整数的个数. 输入格式 2个正整数x0,y0 输出格式 1个数,表示求出满足条件的P,Q的个数 样例输入 3 60 样例输出 4 说明/提示 P,Q有4种: 3,60

poj 1028 Web Navigation 【模拟题】

题目地址:http://poj.org/problem?id=1028 测试样例: Sample Input VISIT http://acm.ashland.edu/ VISIT http://acm.baylor.edu/acmicpc/ BACK BACK BACK FORWARD VISIT http://www.ibm.com/ BACK BACK FORWARD FORWARD FORWARD QUIT Sample Output http://acm.ashland.edu/ ht

poj 1028 Web Navigation(模拟题)

题目链接:http://poj.org/problem?id=1028 Description 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 reac