自己写了一个代码,超时两个点,求帮助
#include<bits/stdc++.h>
using namespace std;
stack<string> forw,back;
string x,url;
int main(){
back.push("https://keda.ac/");
while(1){
cin>>x;
if(x == "VISIT"){
cin>>url;
back.push(url);
while(!forw.empty()) forw.pop();
cout<<back.top()<<endl;
}
else if(x=="BACK"){
if(back.size()<=1) cout<<"Ignored"<<endl;
else{
forw.push(back.top());
back.pop();
cout<<back.top()<<endl;
}
}
else if(x=="FORWARD"){
if(forw.empty()) cout<<"Ignored"<<endl;
else{
back.push(forw.top());
forw.pop();
cout<<back.top()<<endl;
}
}
else break;
}
return 0;
}