/ Graveyard /

记录详情

Wrong Answer


  
# 状态 耗时 内存占用
#1 Wrong Answer 成绩取消 0ms 0 Bytes

代码

#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.acm.org/";
			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:14:44
评测时间
2017-07-09 21:16:42
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes