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 ...
随机推荐
- BootStrap 智能表单系列 五 表单依赖插件处理
这一章比较简单哦,主要就是生产表单元素后的一些后续处理操作,比如日期插件的渲染.一些autocomplete的处理等,在回调里面处理就可以了, demo: $("input.date-pic ...
- ASP.NET MVC导入excel到数据库
MVC导入excel和webform其实没多大区别,以下为代码: 视图StationImport.cshtml的代码: @{ ViewBag.Title = "StationImport&q ...
- ArrayList-VS-LinkedList
ArrayList 是List接口的实现类:底层的数据结构是数组,而LinkedList底层数据结构是双向循环链表. 所以在查询时ArrayList效率高,增删时LinkedList高.由于List中 ...
- UVa12563(DP)
题意:求在给定时间内,最多能唱多少歌曲,在最多歌曲的情况下,使唱的时间最长. 该题类似于01背包问题,可用01背包问题的解题思路来求,每个歌曲相当于物品,歌曲的长度相等于物品重量,每个歌曲的“价值”为 ...
- JZOI
orz..kpm大神做的JZOI卡.很好看 目前是全球限量十张哈哈哈 (正面) (背面) 原图:
- Spring配置机制的优缺点 - Annotation vs XML
转自 http://tianzongqi.iteye.com/blog/1458002 XML配置的优缺点: 优点: XML配置方式进一步降低了耦合,使得应用更加容易扩展,即使对配置文件进一步修改也不 ...
- 5.6.1 Boolean类型
Boolean类型是与布尔值对应的引用类型.要创建Boolean对象,可以像下面这样调用Boolean构造函数并传入true或false值. var booleanObject=new Boolean ...
- HTML+CSS笔记 CSS中级 一些小技巧
水平居中 行内元素的水平居中 </a></li> <li><a href="#">2</a></li> &l ...
- 前端笔试题 JS部分
题目 http://www.itmian4.com/forum.php?mod=viewthread&tid=4540 http://www.itmian4.com/forum.php?mod ...
- C++标准程序库的输入输出流(I/O Stream)复制文件(4种方法)
使用C++标准程序库的输入输出流(I/O Stream)复制文件,存在许多的方法, 方法一:逐个字符复制#include < fstream > std::ifstream ...