文章

30

粉丝

0

获赞

17

访问

3.8k

头像
动态查找问题 题解:
P1477
发布于2026年2月1日 15:45
阅读数 106

Set

#include <iostream> #include <set> using namespace std; int main() { ios::sync_with_stdio(false); // 提速(可选,C++98 支持) int n; cin >> n; set<int> s; for (int i = 0; i < n; ++i) { int num; cin >> num; s.insert(num); } int q; cin >> q; for (int i = 0; i < q; ++i) { int x; cin >> x; if (s.find(x) != s.end()) { cout << "find" << endl; } else { cout << "no" << endl; s.insert(x); // 加入集合 } } return 0; }

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发