/ Graveyard /

记录详情

Accepted


  
# 状态 耗时 内存占用
#1 Accepted 4ms 360.0 KiB
#2 Accepted 5ms 352.0 KiB
#3 Accepted 4ms 256.0 KiB
#4 Accepted 5ms 336.0 KiB

代码

#include<iostream>
#include<string>
#include<stack>

using namespace std;

stack<string> back;
stack<string> forw;

int main(){
	int n;
	cin>>n;
	while(n--){
		string cmd,url="http://www.astrnuts.com/";
			while(!back.empty())
				back.pop();
			while(!forw.empty())
				forw.pop();
			back.push(url);

		while(1){
			cin>>cmd;
			if(cmd=="QUIT")break;
			if(cmd=="VISIT"){
				cin>>url;
				back.push(url);
				cout<<url<<endl;
				while(!forw.empty())	//visit new website, empty the forward stack
					forw.pop();
			}
			if(cmd=="BACK"){
				if(back.size()==1)		//top url is the current 
					cout<<"Ignored"<<endl;
				else{
					forw.push(url);
					back.pop();
					url=back.top();
					cout<<url<<endl;
				}
			}
			if(cmd=="FORWARD"){
				if(forw.empty())
					cout<<"Ignored"<<endl;
				else{
					url=forw.top();
					forw.pop();
					back.push(url);
					cout<<url<<endl;
				}
			}
		}
		if(n>0)
			cout<<endl;
		
	}

	return 0;
} 

信息

递交者
类型
递交
题目
Chrome Navigation Bar Lite 清爽版浏览器导航栏
语言
C++
递交时间
2017-07-09 21:16:52
评测时间
2017-07-09 21:16:52
评测机
分数
70
总耗时
19ms
峰值内存
360.0 KiB