文章
119
粉丝
68
获赞
92
访问
20.1k
#include <bits/stdc++.h>
using namespace std;
int main() {
int n,m;
while(cin>>n>>m){
map<int,int>mp;
while(n--){
int x;cin>>x;
if(mp[x]==0)mp[x]++;
}
set<int>l;
while(m--){
int x;cin>>x;
l.insert(x);
}
for(auto x:l){
mp[x]++;
}
int a=0,b=0;
for(auto x:mp){
if(x.second>1)a++;
b++;
}
cout<<a<<' '<<b<<endl;
}
}
map用于检索集合并交状态,set用于去重
登录后发布评论
暂无评论,来抢沙发