第三个测试点错了。
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int n;
int d1[101], d2[101], d1y[101], d2y[101];
string s1, s2;
int main()
{
cin >> s1 >> s2;
scanf("%d",&n);
while (n --)
{
char c, p;
int t, h;
cin >> t >> c >> h >> p;
if (!d1[h] && !d2[h] && p == 'r')
{
if (c == 'h')
{
d1[h] = 1;
cout << s1 << " " << h << " " << t << endl;
}
else if (c == 'a')
{
d2[h] = 1;
cout << s2 << " " << h << " " << t << endl;
}
}
else if (!d1[h] && !d2[h] && p == 'y')
{
if (c == 'h')
{
d1y[h] ++;
if (d1y[h] == 2)
{
cout << s1 << " " << h << " " << t << endl;
d1[h] = 1;
}
}
else if (c == 'a')
{
d2y[h] ++;
if (d2y[h] == 2)
{
cout << s2 << " " << h << " " << t << endl;
d2[h] = 1;
}
}
}
}
return 0;
}