RC-u2 出院 - 2023 睿抗机器人开发者大赛CAIP-编程技能赛-本科组(省赛) (pintia.cn)
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
string temp1, temp2;
struct P {
string name;
string op;
} a[N];
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++)
cin >> a[i].name >> a[i].op;
for (int i = 0; i < m; i++) {
temp1.clear(), temp2.clear();
string s;
cin >> s;
for (int j = 0; j < n; j++) {
if (s.find(a[j].name) != string::npos) {
temp1 += a[j].op;
temp2 += a[j].name;
}
}
//cout << "temp1 temp2 s: " << temp1 << " " << temp2 << " " << s << endl;
if (temp1 == " ")
cout << "D" << endl;
else if (temp2 != s) {
cout << "D" << endl;
} else {
cout << temp1 << endl;
}
}
return 0;
}