题目:http://codeforces.com/problemset/problem/242/D
其实简单的BFS就可以搞定的。。但是我就是不能看出这个模型= =!!
#include<cstdio>
#include<vector>
#include<queue>
using namespace std;
const int maxn = 100010;
vector<int > ans,v[maxn];
queue<int > q;
int a[maxn],b[maxn];
int main(){
int n,m,v1,v2;
scanf("%d%d",&n,&m);
for(int i=0;i<m;i++){
scanf("%d%d",&v1,&v2);
v[v1].push_back(v2);
v[v2].push_back(v1);
}
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
for(int i=1;i<=n;i++){
if(a[i]==b[i]) q.push(i),ans.push_back(i);
}
while(!q.empty()){
int x=q.front(); q.pop();
b[x]++;
for(int i=0;i<v[x].size();i++){
int y=v[x][i];
b[x]++; b[y]++;
if(b[y]==a[y]){
q.push(y);
ans.push_back(y);
}
}
}
printf("%d\n",ans.size());
for(int i=0;i<ans.size();i++){
printf("%d%c",ans[i],i==ans.size()-1?'\n':' ');
}
return 0;
}