EDqwq @ 2020-11-12 18:20:19
感觉写的没啥问题。。。
帮改题必有重赏
关注一个
by EDqwq @ 2020-11-12 18:20:30
/*
Author : EnderDeer
OnlineJudge : Luogu
*/
#include<bits/stdc++.h>
#define int long long
using namespace std;
int read(){
int s = 0,w = 1;
char ch = getchar();
while(ch < '0' || ch > '9'){if(ch == '-')w = -1;ch = getchar();}
while(ch >= '0' && ch <= '9')s = s * 10 + ch - '0',ch = getchar();
return s * w;
}
int n,m,k;
int pre[200010];
int data1[200010],data2[200010];
int data3[200010];
int ans[200010];
map <int,bool> q;
int find(int x){
if(pre[x] == x)return x;
else return pre[x] = find(pre[x]);
}
void join(int x,int y){
int xx = find(x);
int yy = find(y);
if(xx != yy){
pre[xx] = yy;
}
}
signed main(){
cin>>n>>m;
for(int i = 1;i <= n;i ++)pre[i] = i;
for(int i = 1;i <= m;i ++)data1[i] = read(),data2[i] = read();
cin>>k;
for(int i = 1;i <= k;i ++){
int x;
x = read();
data3[i] = x;
q[x] = true;
}
for(int i = 1;i <= m;i ++){
if(!q[data1[i]] && !q[data2[i]])join(data1[i],data2[i]);
}
for(int i = 0;i <= k;i ++){
int s = 0;
for(int ii = 1;ii <= n;ii ++)if(find(ii) == ii)s ++;
ans[i] = s;
if(i == 0)continue;
q[data3[k - i + 1]] = false;
for(int j = 1;j <= m;j ++){
if(data1[j] == data3[k - i + 1] || data2[j] == data3[k - i + 1]){
join(data1[j],data2[j]);
}
}
}
cout<<"¡ª¡ª¡ª¡ª¡ª¡ªAnswer¡ª¡ª¡ª¡ª¡ª¡ª"<<endl;//
for(int i = k + 1;i >= 1;i --)cout<<ans[i]<<endl;
return 0;
}
by Ryo_Yamada @ 2020-11-12 18:22:08
已经有关注了,果断关闭网页
by 素质玩家孙1超 @ 2020-11-12 18:23:40
赏关注可还行
by icyo @ 2020-11-12 18:28:48
赏关注好评
by LemonSherbet @ 2020-11-12 18:30:08
重赏啊!我看看!几块钱? 哦关注啊 那再见
by oistr @ 2020-11-12 18:31:09
关矣,断关网
by nuo0930 @ 2020-11-12 18:34:00
没仔细看,但这个是不是应该注释
by cccgift @ 2020-11-12 18:36:06
by rui_er @ 2020-11-12 18:36:35
cout<<"¡ª¡ª¡ª¡ª¡ª¡ªAnswer¡ª¡ª¡ª¡ª¡ª¡ª"<<endl;//
by JJA_ @ 2020-11-12 18:40:39
cout<<"¡ª¡ª¡ª¡ª¡ª¡ªAnswer¡ª¡ª¡ª¡ª¡ª¡ª"<<endl;//
———>
//cout<<"¡ª¡ª¡ª¡ª¡ª¡ªAnswer¡ª¡ª¡ª¡ª¡ª¡ª"<<endl;
试试?