这题就是坑人的,因为way我前一半存正图,后一半存反图,导致一般扩大两倍过不了,而是要扩大四倍,就是这个坑!!!!!

 #include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
const int maxn=4e6+;
struct node
{
int val;
int next;
}way[maxn];
queue< int >q;
int n,m;
bool vis[],cover[];
int nex[];
int cnt,head[];
int last[];
int s[],ans;
int tot=;
int add(int x,int y)
{
way[++tot].next=head[x];
way[tot].val=y;
head[x]=tot;
}
void de(int x)
{
nex[last[x]]=nex[x];
last[nex[x]]=last[x];
}
int main()
{
cin>>n>>m;
int x,y;
for(int i=;i<=m;i++)
{
cin>>x>>y;
add(x,y);
add(y,x);
}
//cout<<tot<<endl;
nex[]=;
for(int i=;i<n;i++)
{
last[i+]=i;
nex[i]=i+;
} for(int i=;i<=n;i++)
{
if(!vis[i])
{
s[++ans]=;
vis[i]=true;
q.push(i);
de(i);
// cout<<1111111<<endl;
while(!q.empty())
{
int x=q.front();
q.pop();
for(int j=head[x];j;j=way[j].next)
{
if(!vis[way[j].val])
{
cover[way[j].val]=true;
}
}
for(int j=nex[];j;j=nex[j])
{
if(!cover[j])
{
vis[j]=true;
s[ans]++;
de(j);
q.push(j);
}
else
cover[j]=false;
}
}
}
}
//cout<<1111111<<endl;
sort(s+,s++ans);
cout<<ans<<endl;
for(int i=;i<=ans;i++)
{
cout<<s[i]<<" ";
}
/*cout<<endl<<endl;
for(int i=1;i<=n;i++)
{
cout<<nex[i]<<" ";
}*/
return ;
}

洛谷P3452 [POI2007]BIU-Offices的思考的更多相关文章

  1. [洛谷P3460] [POI2007]TET-Tetris Attack

    洛谷题目链接:[POI2007]TET-Tetris Attack 题目描述 A puzzle called "Tetris Attack" has lately become a ...

  2. [洛谷3457][POI2007]POW-The Flood

    洛谷题目链接:[POI2007]POW-The Flood 题意翻译 Description 你手头有一张该市的地图.这张地图是边长为 m∗n 的矩形,被划分为m∗n个1∗1的小正方形.对于每个小正方 ...

  3. 洛谷P3459 [POI2007]MEG-Megalopolis(树链剖分,Splay)

    洛谷题目传送门 正解是树状数组维护dfn序上的前缀和,这样的思路真是又玄学又令我惊叹( 我太弱啦,根本想不到)Orz各路Dalao 今天考了这道题,数据范围还比洛谷的小,只有\(10^5\)(害我复制 ...

  4. 洛谷P3459 [POI2007]MEG-Megalopolis [树链剖分]

    题目传送门 MEG 题目描述 Byteotia has been eventually touched by globalisation, and so has Byteasar the Postma ...

  5. 洛谷 P3462 [POI2007]ODW-Weights

    题面: https://www.luogu.org/problemnew/show/P3462 https://www.lydsy.com/JudgeOnline/problem.php?id=111 ...

  6. Connected Components? Codeforces - 920E || 洛谷 P3452 &&bzoj1098 [POI2007]BIU-Offices

    https://codeforces.com/contest/920/problem/E https://www.luogu.org/problemnew/show/P3452 https://www ...

  7. 洛谷 P3456 [POI2007]GRZ-Ridges and Valleys

    P3456 [POI2007]GRZ-Ridges and Valleys 题意翻译 给定一个地图,为小朋友想要旅行的区域,地图被分为n*n的网格,每个格子(i,j) 的高度w(i,j)是给定的.若两 ...

  8. 洛谷 P3455 [POI2007]ZAP-Queries (莫比乌斯函数)

    题目链接:P3455 [POI2007]ZAP-Queries 题意 给定 \(a,b,d\),求 \(\sum_{x=1}^{a} \sum_{y=1}^{b}[gcd(x, y) = d]\). ...

  9. 洛谷P3459 [POI2007]MEG-Megalopolis [2017年6月计划 树上问题02]

    [POI2007]MEG-Megalopolis 题目描述 Byteotia has been eventually touched by globalisation, and so has Byte ...

随机推荐

  1. Java字段初始化规律

    首先先附上一段代码:public class InitializeBlockDemo { public static void main(String[] args) { InitializeBloc ...

  2. react-native开发经验

    # **RN开发经验** ## 一.环境配置关于环境配置,前辈已有完整的总结:http://tvrn.devops.letv.com/docs/Environment.html **IDE准备:** ...

  3. python 学习之 基础篇一 python及pycharm的安装

    一. Python 环境搭建(安装请参照https://www.runoob.com/python/python-install.html) Python下载 Python官网:https://www ...

  4. C# .Net Framework

    .NET Framework概述 .NET Framework是由微软开发,一个致力于敏捷软件开发.快速应用开发.平台无关性和网络透明化的软件开发平台. .NET Framework组成 .NET F ...

  5. windows上gedit 安装

    1. 用浏览器打开https://wiki.gnome.org/Apps/Gedit 下载并安装 gedit 文本编辑器.这个操作无需管理员权限. 2. 把 gedit 放到桌面或者快速启动栏,这样你 ...

  6. Roadmap of FE

    未完待补充......

  7. Python3的编码整理总结

    python3在内存中是用unicode编码方式存储的,所以不能直接储存和传输,要转化为其他编码进行储存和传输. 字符串通过编码转换成字节码,字节码通过解码成为字符串 encode:str --> ...

  8. windows系统安全日志取证工具

    0x01 关于日志 Windows安全事件日志中详细记录了是谁在什么时候通过什么手段登录到系统或者注销了登录,通过分析该日志可以详细了解服务器的安全情况以及必要时的取证工作. 0x02 查看日志 传统 ...

  9. php注释的作用是什么?

    php注释的作用 1.解释代码功能: 2.调试程序. 说明:在代码中进行注释是很有必要的,规范的注释使的源代码更易于人类理解,可以帮助我们理解别人或者自己以前编写的代码. php怎么添加注释? 1.用 ...

  10. linux 中more、less 和 most 的区别

    如果你是一个 Linux 方面的新手,你可能会在 more.less.most 这三个命令行工具之间产生疑惑.在本文当中,我会对这三个命令行工具进行对比,以及展示它们各自在 Linux 中的一些使用例 ...