题解 | #查找#
查找
https://www.nowcoder.com/practice/d93db01c2ee44e8a9237d63842aca8aa
#include <iostream> #include <map> using namespace std; int main() { int n,m; cin>>n; map<int,bool> mp; while(n--){ int temp; cin>>temp; mp[temp]=true; } cin>>m; while(m--){ int temp; cin>>temp; if(mp.find(temp)!=mp.end()) cout<<"YES"<<endl; else cout<<"NO"<<endl; } } // 64 位输出请用 printf("%lld")