PKU 1028
#include <stack> #include <string> #include <iostream> using namespace std; int main(){ string s, c ("http://www.acm.org/"); stack<string> f,b; while(1){ cin>>s; if(s == "QUIT") break; if(s == "BACK"){ if(b.empty()){ cout<<"Ignored\n"; continue; } f.push(c); c = b.top(); b.pop(); }else if(s == "FORWARD"){ if(f.empty()){ cout<<"Ignored\n"; continue; } b.push(c); c = f.top(); f.pop(); }else if(s == "VISIT"){ b.push(c); while(!f.empty()) f.pop(); cin>>c; } cout<<c<<endl; } return 0; }
簡単な問題を先に解いて逃げる戦法。しかも簡単な筈の問題で1回wrong answerされる、っていう…
ちゃんと問題文を読みましょうという事でした。