第一个题解
2025-11-06 20:08:17
发布于:浙江
1阅读
0回复
0点赞
#include <iostream>
#include <unordered_set>
#include <string>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
cin.ignore(); // 忽略n后面的换行符
unordered_set<string> books;
for (int i = 0; i
for (int i = 0; i < n; ++i) {
string op, name;
// 读取操作类型
getline(cin, op, ' ');
// 读取书名(剩余部分)
getline(cin, name);
if (op == "add") {
books.insert(name);
} else if (op == "find") {
if (books.count(name)) {
cout << "yes\n";
} else {
cout << "no\n";
}
}
}
return 0;
}
这里空空如也







有帮助,赞一个