Saturday, 21 March 2009

POJ ( acm.pku.edu.cn ) 1028





#include <iostream>
#include <deque>
#include <string>
using namespace std;

int main()
{
char instu[16]; string url;
deque<string> b,f;
b.push_back("http://www.acm.org/");
while(cin>>instu){
switch(*instu){
case 'V':
f.clear(); if(url!="") b.push_back(url);
cin>>url;
cout<<url<<endl;
break;
case 'B':
if(b.empty())
cout<<"Ignored"<<endl;
else {
f.push_back(url);
url=b.back();
b.pop_back();
cout<<url<<endl;
}
break;
case 'F':
if(f.empty())
cout<<"Ignored"<<endl;
else {
b.push_back(url);
url=f.back();
f.pop_back();
cout<<url<<endl;
}
break;
default:
return 0;
}
}
return 0;
}

No comments:

Post a Comment