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的更多相关文章

  1. BZOJ 1015 题解

    1015: [JSOI2008]星球大战starwar Description 很久以前,在一个遥远的星系,一个黑暗的帝国靠着它的超级武器统治者整个星系.某一天,凭着一个偶然的机遇,一支反抗军摧毁了帝 ...

  2. BZOJ 1015: [JSOI2008]星球大战starwar 并查集

    1015: [JSOI2008]星球大战starwar Description 很久以前,在一个遥远的星系,一个黑暗的帝国靠着它的超级武器统治者整个星系.某一天,凭着一个偶然的机遇,一支反抗军摧毁了帝 ...

  3. BZOJ 1015 星球大战

    Description 很久以前,在一个遥远的星系,一个黑暗的帝国靠着它的超级武器统治者整个星系.某一天,凭着一个偶然的机遇,一支反抗军摧毁了帝国的超级武器,并攻下了星系中几乎所有的星球.这些星球通过 ...

  4. BZOJ 1015 [JSOI2008]星球大战starwar

    1015: [JSOI2008]星球大战starwar Time Limit: 3 Sec  Memory Limit: 162 MBSubmit: 3551  Solved: 1581[Submit ...

  5. bzoj 1015: [JSOI2008]星球大战starwar (逆向思维+并查集)

    链接:https://www.lydsy.com/JudgeOnline/problem.php?id=1015 思路: 题目是要我们对当前图拆掉k个点,问,每拆一个点后图中有多少个联通块,我们可以逆 ...

  6. BZOJ 1015: [JSOI2008]星球大战starwar(并查集求连通块+离线处理)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1015 题意: 思路:好题啊!!! 这道题目需要离线处理,先把所有要删的点给保存下来,然后逆序加点,这 ...

  7. BZOJ 1015 星球大战starwar 逆向并查集

    题目链接: https://www.lydsy.com/JudgeOnline/problem.php?id=1015 题目大意: 很久以前,在一个遥远的星系,一个黑暗的帝国靠着它的超级武器统治者整个 ...

  8. bzoj 1015 维护连通块个数,离线并查集

    水. /************************************************************** Problem: 1015 User: idy002 Langua ...

  9. bzoj 1015 星球大战starwar

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1015 题解: 如果按照题目的意思,每次删点.删边太困难了……于是采用逆向思维,构造出最后的 ...

  10. BZOJ 1015 并查集+离线倒序

    统计块个数写错了调了好久啊,BZOJ1696的弱化版本. #include <iostream> #include <cstring> #include <algorit ...

随机推荐

  1. 设计模式入门之桥接模式Bridge

    Abstraction:抽象部分的父类,定义须要实现的接口.维护对实现部分的引用,从而把实现桥接到Implementor中去 Implementor:实现部分的接口 RefinedAbstractio ...

  2. 有感PMI Exam Dev Workshop

    有幸參加了PMI协会在上海举办的PMI Exam Development Workshop活动.这是PMI协会第二次在中国举办此活动,上一次是2009年北京. 我第一次參加,感觉收获非常多. 我们知道 ...

  3. 3. 表单输入框 在 IE 中 会有 “X” 和 类似wifi图标的图标出现

    原因: IE 自动给 input加了伪类 ::ms-clear 和 ::ms-reveal 解决: input::ms-clear, input::ms-reveal { display: none; ...

  4. CodeForces 452C Magic Trick (排列组合)

    #include <iostream> #include <cstdio> #include<cmath> #include<algorithm> us ...

  5. objective-C学习笔记(九)ARC

    ARC叫自动引用计数Automatic Reference Counting.针对堆上的对象,管理对象的创建和释放. 哪些对象受ARC管理: OC对象指针 Block指针 使用_attribute_( ...

  6. Tomcat 启动 Debug模式

    如果debug启动遇到如下错误: ERROR: transport error 202: gethostbyname: unknown host ERROR: JDWP Transport dt_so ...

  7. 帝国cms7.0调用指定栏目,指定顺序排列

    [e:loop={"select * from {$dbtbpre}enewsclass where classid in (82,83,86,87,88,89,90,91,93) orde ...

  8. <Win32_16>来看看标准菜单和右键菜单的玩法

    日常应用中,菜单主要分为两种:(1) 标准菜单(处于应用程序菜单栏处的菜单)    (2)右键快捷菜单 几乎你所见过或使用过的软件中,都有它俩儿 为应用程序添加它们的基本步骤: (1)用代码或者IDE ...

  9. Python+django开发环境搭建

    Python目前主版本有2个,2.7+和3.4+ 新入手,决定还是从2.7开始 先从python官网https://www.python.org/下载python2.7.10,64位版本(这里注意,选 ...

  10. Home | WebScraping.com

    Home | WebScraping.com We specialize in extracting data from websites, which is known as web scrapin ...