文章
34
粉丝
18
获赞
6
访问
14.5k
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
const int N = 1e5 + 10;
int a[N],b[N],c[N];
bool f[N];
int main(){
int n,cnt = 0;
cin >> n;
memset(f,false,sizeof(f));
memset(c,0,sizeof(c));
for(int i = 0;i < n;i ++){
cin >> a[i];
f[a[i]] = true;
}
for(int i = 0,j = 0;i < n;i ++){
cin >> b[i];
if(f[b[i]]){
c[j ++] = b[i];
cnt ++;
}
}
sort(c,c + n);
cout << cnt << endl;
for(int i = 0;i < n;i ++){
if(c[i] != 0){
cout << c[i] << " ";
}
}
cout << endl;
return 0;
}
登录后发布评论
暂无评论,来抢沙发