BZOJ 1015
program bzoj1015;
{$inline on} const maxn=; type node=record
togo,next:longint;
end; var tot,n,m,d,cnt:longint;
father,head,q,ans:array [..maxn] of longint;
used,des:array [..maxn] of boolean;
e:array [..maxn] of node; function find(x:longint):longint; inline;
begin
if father[x]=x then exit(x);
if father[father[x]]=x then exit(father[x]);
find:=find(father[x]);
father[x]:=find;
end; procedure ins(u,v:longint); inline;
begin
inc(cnt);
e[cnt].togo:=v; e[cnt].next:=head[u]; head[u]:=cnt;
inc(cnt);
e[cnt].togo:=u; e[cnt].next:=head[v]; head[v]:=cnt;
end; procedure add(x:longint); inline;
var i,p,q:longint;
begin
i:=head[x];
p:=find(x);
while i<> do
begin
if used[e[i].togo] then
begin
q:=find(e[i].togo);
if p<>q then
begin
father[q]:=p;
dec(tot);
end;
end;
i:=e[i].next;
end;
end; procedure main;
var i,x,y:longint;
begin
read(n,m);
cnt:=;
for i:= to n- do father[i]:=i;
for i:= to m do
begin
read(x,y);
ins(x,y);
end;
read(d);
for i:= to d do
begin
read(q[i]);
des[q[i]]:=true;
end;
for i:= to n- do
if not(des[i]) then
begin
inc(tot);
add(i);
used[i]:=true;
end;
ans[d+]:=tot;
for i:=d downto do
begin
inc(tot);
add(q[i]);
used[q[i]]:=true;
ans[i]:=tot;
end;
for i:= to d+ do
writeln(ans[i]);
end; begin
main;
end.
BZOJ 1015的更多相关文章
- BZOJ 1015 题解
1015: [JSOI2008]星球大战starwar Description 很久以前,在一个遥远的星系,一个黑暗的帝国靠着它的超级武器统治者整个星系.某一天,凭着一个偶然的机遇,一支反抗军摧毁了帝 ...
- BZOJ 1015: [JSOI2008]星球大战starwar 并查集
1015: [JSOI2008]星球大战starwar Description 很久以前,在一个遥远的星系,一个黑暗的帝国靠着它的超级武器统治者整个星系.某一天,凭着一个偶然的机遇,一支反抗军摧毁了帝 ...
- BZOJ 1015 星球大战
Description 很久以前,在一个遥远的星系,一个黑暗的帝国靠着它的超级武器统治者整个星系.某一天,凭着一个偶然的机遇,一支反抗军摧毁了帝国的超级武器,并攻下了星系中几乎所有的星球.这些星球通过 ...
- BZOJ 1015 [JSOI2008]星球大战starwar
1015: [JSOI2008]星球大战starwar Time Limit: 3 Sec Memory Limit: 162 MBSubmit: 3551 Solved: 1581[Submit ...
- bzoj 1015: [JSOI2008]星球大战starwar (逆向思维+并查集)
链接:https://www.lydsy.com/JudgeOnline/problem.php?id=1015 思路: 题目是要我们对当前图拆掉k个点,问,每拆一个点后图中有多少个联通块,我们可以逆 ...
- BZOJ 1015: [JSOI2008]星球大战starwar(并查集求连通块+离线处理)
http://www.lydsy.com/JudgeOnline/problem.php?id=1015 题意: 思路:好题啊!!! 这道题目需要离线处理,先把所有要删的点给保存下来,然后逆序加点,这 ...
- BZOJ 1015 星球大战starwar 逆向并查集
题目链接: https://www.lydsy.com/JudgeOnline/problem.php?id=1015 题目大意: 很久以前,在一个遥远的星系,一个黑暗的帝国靠着它的超级武器统治者整个 ...
- bzoj 1015 维护连通块个数,离线并查集
水. /************************************************************** Problem: 1015 User: idy002 Langua ...
- bzoj 1015 星球大战starwar
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1015 题解: 如果按照题目的意思,每次删点.删边太困难了……于是采用逆向思维,构造出最后的 ...
- BZOJ 1015 并查集+离线倒序
统计块个数写错了调了好久啊,BZOJ1696的弱化版本. #include <iostream> #include <cstring> #include <algorit ...
随机推荐
- 如何上传base64编码图片到七牛云
接口说明 POST /putb64/<Fsize>/key/<EncodedKey>/mimeType/<EncodedMimeType>/crc32/<Cr ...
- Javascript 递归函数
递归函数就是在函数内部调用它自己.在Javascript 中有很多写法,值得我们学习一下(Javascript太灵活了).还是用n的 阶乘 来写例子吧. 1. 首先,来看一个最普通 最正常的写法. f ...
- w3c教程
http://www.w3cfuns.com/course.php http://www.w3cfuns.com/home.php?mod=space&uid=5434413&do=b ...
- django datetime format 日期格式化
django datetime format 日期格式化 www.jx-lab.com python 中 date,datetime,time对象都支持strftime(format)方法,但有一些区 ...
- Junit 测试常见错误
1. java.lang.Exception: No tests found matching Method deleteUser(mybatis.dao.Usertest) from org.jun ...
- Problem E: Product
Problem E: ProductTime Limit: 1 Sec Memory Limit: 128 MBSubmit: 18 Solved: 14[Submit][Status][Web Bo ...
- 5.6.3 String类型
String类型是字符串的对象包装类型,可以像下面这样使用String构造函数来创建. var stringObject = new String("hello world"); ...
- 创建android 模拟器并在cmd中打开
因为在运行monkeyrunner之前必须先运行相应的模拟器或连接真机,否则monkeyrunner无法连接到设备,运行模拟器有两种方法:1.通过eclipse中执行模拟器 2.在CMD中通过命令调用 ...
- java 写文件解析
import java.io.File; import java.io.FileOutputStream; import java.io.*; public class FileTest { publ ...
- codeforces 451E. Devu and Flowers 容斥原理+lucas
题目链接 给n个盒子, 每个盒子里面有f[i]个小球, 然后一共可以取sum个小球.问有多少种取法, 同一个盒子里的小球相同, 不同盒子的不同. 首先我们知道, n个盒子放sum个小球的方式一共有C( ...