题解 | 查找
#include <bits/stdc++.h> using namespace std; int main(){ int n; while(cin>>n){ map<int,int>mp; while(n--){ int k;cin>>k; mp[k]++; } int m;cin>>m; while (m--) { int k;cin>>k; if(mp[k]!=0)cout<<"YES"<<endl; else cout<<"NO"<<endl; } } }
map,set,排序,都可以解