#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int a;
cin >> a;
vector<string> queue;
vector<string> playing;
for (int i = 0; i < a; i++) {
string command;
cin >> command;
if (command == "start") {
if (queue.empty()) {
cout << "Error" << endl;
} else {
if (!playing.empty()) {
queue.insert(queue.end(), playing.begin(), playing.end());
}
playing.clear();
playing.push_back(queue.front());
queue.erase(queue.begin());
if (!queue.empty()) {
playing.push_back(queue.front());
queue.erase(queue.begin());
}
for (const auto &player : playing) {
cout << player << " ";
}
cout << endl;
}
} else if (command == "arrive") {
string name;
cin >> name;
if (find(queue.begin(), queue.end(), name) == queue.end() && find(playing.begin(), playing.end(), name) == playing.end()) {
queue.push_back(name);
cout << "OK" << endl;
} else {
cout << "Error" << endl;
}
} else if (command == "leave") {
string name;
cin >> name;
auto it = find(queue.begin(), queue.end(), name);
if (it != queue.end() && find(playing.begin(), playing.end(), name) == playing.end()) {
queue.erase(it);
cout << "OK" << endl;
} else {
cout << "Error" << endl;
}
}
}
return 0;
}
模拟求调