题解 C++ map
查找
https://www.nowcoder.com/practice/d93db01c2ee44e8a9237d63842aca8aa
#include <bits/stdc++.h> using namespace std; int main(){ int n,m,x; map<int,int> mp; while(cin>>n){ for(int i=0;i<n;i++){ cin>>x; mp[x]++; } cin>>m; for(int i=0;i<m;i++){ cin>>x; if(mp[x]>0) cout<<"YES"<<endl; else cout<<"NO"<<endl; } } return 0; }