rt,赛时是 AC 了的,然后被 Hack 掉了,但是是 WA 掉的
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5 + 5;
int n, cnt, b;
vector<int> a;
map<string, int> mp;
string k[N];
bool flag;
signed main()
{
cin >> n;
for(int i = 1; i <= n; i++)
{
string S;
cin >> S;
if(S == "start")
{
// cout << S << " ";
if(a.empty())
{
cout << "Error\n";
// continue;
}
else if(a.size() == 1)
cout << k[a[0]] << "\n", b = 1;
else
{
if(flag)
{
// cout << b << "\n";
for(int j = 0; j < b; j++)
{
// vector<int>::iterator iter = find(begin(a), end(a), a[j]);
a.push_back(a[0]);
a.erase(a.begin());
}
}
cout << k[a[0]] << " " << k[a[1]] << "\n";
b = 2;
}
flag = true;
}
else if(S == "arrive")
{
// cout << S << " ";
cin >> S;
int s;
if(!mp[S])
mp[S] = ++cnt, k[cnt] = S;
s = mp[S];
vector<int>::iterator iter = find(a.begin(), a.end(), s);
if(iter == a.end())
cout << "OK\n", a.push_back(s);
else
cout << "Error\n";
}
else
{
// cout << S << " ";
cin >> S;
int s;
if(!mp[S])
mp[S] = ++cnt, k[cnt] = S;
s = mp[S];
vector<int>::iterator iter = find(begin(a), end(a), s);
int id = iter - begin(a);
if(id == 0 || id == 1 || iter == a.end())
cout << "Error\n";
else
cout << "OK\n", a.erase(iter);
}
// for(auto l : a)
// cout << k[l] << " ";
// cout << "\n";
}
return 0;
}