#include<bits/stdc++.h>
using namespace std;
#define ffor(i, a, b) for(int i = (a); i<(b); i++)
const int maxn = 1e6+3;
int N, M, know[maxn], peo[10010];//know知道的情侣,peo来的人
bool flag[maxn], came[maxn];//flag是不是单身,came某个人来没来
vector<int> ve;
int main(){
ios::sync_with_stdio(false);
cin>>N;
ffor(i, 0, N) {
int x, y; cin >>x >>y;
flag[x]=flag[y]=true;
know[x]=y; know[y]=x;
}
cin >>M;
ffor(i, 0, M){
cin >>peo[i];
came[peo[i]]=true;
}
ffor(i, 0, M){
if(flag[peo[i]] && came[know[peo[i]]]) continue;//除了有对象并且对象来了的人,全部加入
ve.push_back(peo[i]);
}
int x =ve.size();
sort(ve.begin(), ve.end());
cout <<x <<endl;
if(x) printf("%05d", ve[0]);
ffor(i, 1,x) printf(" %05d", ve[i]);
return 0;
}
PTA 单身狗
最新推荐文章于 2023-12-19 20:39:34 发布