这题就是坑人的,因为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. js对数组、对象的深拷贝、复制

    基本类型的数据是存放在栈内存中的,而引用类型的数据是存放在堆内存中的 基本类型:Number Boolean undefined String Null 引用类型:Object Function js ...

  2. 小游戏:200行python代码手写2048

    #-*- coding: utf-8 -*- import curses from random import randrange, choice from collections import de ...

  3. 【源码解析】自动配置的这些细节不知道,别说你会 springboot

    spring-boot 相对于 spring,很重要的一个特点就是自动配置,使约定大于配置思想成功落地.xxx-spring-boot-starter 一系列引导器能够开箱即用,或者只需要很少的配置( ...

  4. Java求和的整体思路

    一.    设计思想: 设计这个程序我们需要考虑到参数的输入,并且可以输入多个参数,以及为用户考虑到各种的边界问题.首先第一步我们应该给出输入参数的语句,让用户可以输入.第二步我们应对其进行参数个数的 ...

  5. jQuery.noConflict()解决imgBox.js依赖jquery版本问题

    jQuery提供两种点击图片放大效果出处 在使用imgbox.js是出现的jquery版本不兼容问题,之后了解到jQuery.noConflict()的用法 jQuery.noConflict()的存 ...

  6. linux上安装LAMP笔记

    B哥最近在参加比赛,需要把一个php项目部署到服务器上,故此在linux上安装LAMP环境,用于部署项目,第一次安装,做点儿笔记记录一下. 安装条件: Redhat或者CentOS linux环境已装 ...

  7. 攻防世界(XCTF)WEB(进阶区)write up(四)

    ics-07  Web_php_include  Zhuanxv Web_python_template_injection ics-07 题前半部分是php弱类型 这段说当传入的id值浮点值不能为1 ...

  8. php服务器有哪些

    服务器按照功能可以分为:文件服务器.数据库服务器.web服务器.邮件服务器.代理服务器..... 而上述所有的服务器,均可以用php做开发,比如说做web服务器,常用的构架是php+Mysql+Apa ...

  9. Arduino学习笔记⑤ 模拟IO实验

    1.前言     还记得前几个我们都是在讲解数字IO,而其实我们生活中大多数信号都是模拟信号,如声音以及温度变化.在Arduino中,常用0~5v的电压来表示模拟信号. 1.1 模拟输入功能      ...

  10. 页面报错常用状态码总结(Http常见状态码)

    作为一个互联网开发人员对于一些服务器返回的HTTP状态的意思都必须是了如指掌的,只有将这些状态码一一弄清楚,工作中遇到的各种问题才能够处理的得心应手.好了,下面就让我们来了解一下比较常见的HTTP状态 ...