这两题很类似,都是在补图上搜索

但是由于补图太大我们不能建出来

考虑先从一个点搜,每次搜可以搜的点,

然后维护一个链表,记录当前还没有搜过的点,搜过之后从链表中删除即可

 type node=record
po,next:longint;
end; var e:array[..] of node;
l:array[..] of node;
p,q,ans:array[..] of longint;
can,v:array[..] of boolean;
s,i,n,m,len,x,y:longint; procedure add(x,y:longint);
begin
inc(len);
e[len].po:=y;
e[len].next:=p[x];
p[x]:=len;
end; procedure swap(var a,b:longint);
var c:longint;
begin
c:=a;
a:=b;
b:=c;
end; procedure sort(l,r:longint);
var i,j,x:longint;
begin
i:=l;
j:=r;
x:=ans[(l+r) shr ];
repeat
while ans[i]<x do inc(i);
while x<ans[j] do dec(j);
if not(i>j) then
begin
swap(ans[i],ans[j]);
inc(i);
dec(j);
end;
until i>j;
if l<j then sort(l,j);
if i<r then sort(i,r);
end; procedure del(i:longint);
begin
l[l[i].po].next:=l[i].next;
if l[i].next<>- then l[l[i].next].po:=l[i].po;
end; procedure bfs;
var f,r,i,t:longint;
begin
while l[].next<>- do
begin
f:=;
r:=;
v[l[].next]:=true;
q[]:=l[].next;
del(l[].next);
t:=;
while f<=r do
begin
x:=q[f];
i:=p[x];
while i<> do
begin
can[e[i].po]:=true;
i:=e[i].next;
end;
i:=l[].next;
while i>- do
begin
if not v[i] and not can[i] then
begin
inc(r);
q[r]:=i;
del(i);
inc(t);
v[i]:=true;
end;
i:=l[i].next;
end;
i:=p[x];
while i<> do
begin
can[e[i].po]:=false;
i:=e[i].next;
end;
inc(f);
end;
inc(s);
ans[s]:=t;
end;
end; begin
readln(n,m);
for i:= to m do
begin
readln(x,y);
add(x,y);
add(y,x);
end;
for i:= to n do
begin
l[i].po:=i-;
l[i-].next:=i;
end;
l[n].next:=-;
bfs;
sort(,s);
writeln(s);
for i:= to s do
write(ans[i],' ');
writeln;
end.

1098

 type node=record
po,next:longint;
end; var e:array[..] of node;
l:array[..] of node;
p:array[..] of longint;
can:array[..] of boolean;
i,n,m,x,y,len:longint; procedure add(x,y:longint);
begin
inc(len);
e[len].po:=y;
e[len].next:=p[x];
p[x]:=len;
end; procedure del(i:longint);
begin
l[l[i].po].next:=l[i].next;
if l[i].next<>- then l[l[i].next].po:=l[i].po;
end; procedure dfs(x:longint);
var i,j:longint;
begin
writeln(x);
del(x);
i:=p[x];
while i<> do
begin
can[e[i].po]:=true;
i:=e[i].next;
end;
i:=l[].next;
while i>- do
begin
if not can[i] then
begin
j:=p[x];
while j<> do
begin
can[e[j].po]:=false;
j:=e[j].next;
end;
dfs(i);
exit;
end;
i:=l[i].next;
end;
end; begin
readln(n,m);
for i:= to m do
begin
readln(x,y);
add(x,y);
add(y,x);
end;
for i:= to n do
begin
l[i-].next:=i;
l[i].po:=i-;
end;
l[n].next:=-;
dfs();
end.

1301

bzoj1098 1301的更多相关文章

  1. 【bzoj1098】办公楼

    [bzoj1098]办公楼 题意 FGD开办了一家电话公司.他雇用了N个职员,给了每个职员一部手机.每个职员的手机里都存储有一些同事的电话号码.由于FGD的公司规模不断扩大,旧的办公楼已经显得十分狭窄 ...

  2. HDOJ 1301

    9852303 2013-12-18 11:47:01 Accepted 1301 0MS 264K 1117 B C++ 泽泽 Jungle Roads Time Limit: 2000/1000 ...

  3. hdu 1301 Jungle Roads 最小生成树

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1301 The Head Elder of the tropical island of Lagrish ...

  4. HDOJ 1301 Jungle Roads

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1301 //HDOJ1301 #include<iostream>#include<c ...

  5. hihocoder #1301 : 筑地市场 数位dp+二分

    题目链接: http://hihocoder.com/problemset/problem/1301?sid=804672 题解: 二分答案,每次判断用数位dp做. #include<iostr ...

  6. hdu 1301 Jungle Roads

    http://acm.hdu.edu.cn/showproblem.php?pid=1301 #include <cstdio> #include <cstring> #inc ...

  7. Hdu 1301 Jungle Roads (最小生成树)

    地址:http://acm.hdu.edu.cn/showproblem.php?pid=1301 很明显,这是一道“赤裸裸”的最小生成树的问题: 我这里采用了Kruskal算法,当然用Prim算法也 ...

  8. (最小生成树)Jungle Roads -- HDU --1301

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=1301 http://acm.hust.edu.cn/vjudge/contest/view.action ...

  9. hihocoder #1301 : 筑地市场 二分+数位dp

    #1301 : 筑地市场 题目连接: http://hihocoder.com/problemset/problem/1301 Description 筑地市场是位于日本东京都中央区筑地的公营批发市场 ...

随机推荐

  1. 如何利用VS2010安装和部署应用程序

    转自:http://jingyan.baidu.com/article/4b52d70255d7f0fc5d774b4d.html 1.假设你当前的winform已经okay了 2.解决方案中新建&q ...

  2. discuz 注册用户用到的几个表

    通过开启记录:mysql记录日志,筛出如下信息: INSERT INTO `userclub`.pre_ucenter_members SET secques='', username='pthlp1 ...

  3. 部门招聘开发人员(python相关)

    岗位职责: 1.参与需求分析,产品设计,功能开发: 2.负责系统平台的日常维护: 3.与团队技术交流,共同进步 任职要求: 1.精通Python:对Python有兴趣. 2.熟悉MVC架构,精通Dja ...

  4. 50个C++源码学习网站

    C/C++是最主要的编程语言.这里列出了50名优秀网站和网页清单,这些网站提供c/c++源代码 .这份清单提供了源代码的链接以及它们的小说明.我已尽力包括最佳的C/C++源代码的网站.这不是一个完整的 ...

  5. 每日一记:搭建Memcached + php 缓存系统

    服务器环境,Centos6.5 1.安装Memcached服务端 Yum -y install memcached 2.配置Memcached服务端用户以及自动启动服务等 将服务配置成自启动 chkc ...

  6. 懒惰的JY--关于遍历

    先上题: [问题描述] 众所周知,JY的百度搜索算法已经练的炉火纯青,任何搜索题都能0.000ms出解. 不幸的是,JY遇到了一道百度搜索算法解决不了的题目,题目是这样的: 给定N个数A[1] A[2 ...

  7. python学习笔记8(表达式和语句)

    一.print 和 import 信息 >>> print 'age:',22 # 用逗号隔开打印多个表达式 age: 22 import somemodule # 从模块导入函数 ...

  8. DXperience-12.1.5 官网下载+注册破解+帮助文档

    安装包 DXperience 12.1.5 Universal 帮助文档: DXperienceHelp2010 DXperienceHelp2010-12.1.5.exe DXperienceHel ...

  9. DirectX考试判卷心得

    今天帮老师判<三维图形程序设计>的试卷,这门课开卷考,用的教材是段菲翻译的DX9的龙书.判卷过程中发现有两道题虽然不难,但是错的比较多: 1.Direct3D中深度缓冲区中值的范围? A. ...

  10. 1191: [HNOI2006]超级英雄Hero - BZOJ

    Description 现在电视台有一种节目叫做超级英雄,大概的流程就是每位选手到台上回答主持人的几个问题,然后根据回答问题的多少获得不同数目的奖品或奖金.主持人问题准备了若干道题目,只有当选手正确回 ...