#include <bits/stdc++.h>
using namespace std;
#define puter {cout<<"Error"<<endl;continue;}
#define ok {cout<<"OK"<<endl;continue;}
queue<string> q;
set<string> st;
map <string,bool> vis;
string playa = "" , playb = "";
string take_out(){
string s;
if (st.empty()) return "";
while (1){
s = q.front();q.pop();
if (vis[s]) break;
}
return s;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
for (int i = 1;i <= n ;i++){
string s;
cin >> s;
string x;
if (s == "start"){
if (st.empty()) puter;
if (playa != "") q.push(playa);
if (playb != "") q.push(playb);
string a = take_out() ;
playa = a;
string b = "";
if (st.size() > 1) b = take_out();
playb = b;
cout << a << ' ' << b << endl;
}
else if (s == "arrive"){
cin >> x;
if (vis[x]) puter;
st.insert(x);
q.push(x);
vis[x] = 1;
ok;
}
else {
cin >> x;
if (!vis[x]) puter;
if (x == playa || x == playb) puter;
st.erase(x);
vis[x] = 0;
ok;
}
}
return 0;
}
提交记录