E. Connected Components?
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

You are given an undirected graph consisting of n vertices and edges. Instead of giving you the edges that exist in the graph, we give you m unordered pairs (x, y) such that there is no edge between x and y, and if some pair of vertices is not listed in the input, then there is an edge between these vertices.

You have to find the number of connected components in the graph and the size of each component. A connected component is a set of vertices X such that for every two vertices from this set there exists at least one path in the graph connecting these vertices, but adding any other vertex to X violates this rule.

Input

The first line contains two integers n and m (1 ≤ n ≤ 200000, ).

Then m lines follow, each containing a pair of integers x and y (1 ≤ x, y ≤ n, x ≠ y) denoting that there is no edge between x and y. Each pair is listed at most once; (x, y) and (y, x) are considered the same (so they are never listed in the same test). If some pair of vertices is not listed in the input, then there exists an edge between those vertices.

Output

Firstly print k — the number of connected components in this graph.

Then print k integers — the sizes of components. You should output these integers in non-descending order.

Example
Input
5 5
1 2
3 4
3 2
4 2
2 5
Output
2
1 4

这题是求补图的联通块个数。用到了链表加bfs的强优化。
本人学习博客:http://blog.csdn.net/just_sort/article/details/54862268

codeforces 920E(非原创)的更多相关文章

  1. codeforces 6E (非原创)

    E. Exposition time limit per test 1.5 seconds memory limit per test 64 megabytes input standard inpu ...

  2. Linux下high CPU分析心得【非原创】

    非原创,搬运至此以作笔记, 原地址:http://www.cnitblog.com/houcy/archive/2012/11/28/86801.html 1.用top命令查看哪个进程占用CPU高ga ...

  3. CSS样式命名整理(非原创)

    非原创,具体出自哪里忘了,如果侵害您的利益,请联系我. CSS样式命名整理 页面结构 容器: container/wrap 整体宽度:wrapper 页头:header 内容:content 页面主体 ...

  4. 非原创。使用ajax加载控件

    非原创.来自博客园老赵. public class ViewManager<T> where T : System.Web.UI.UserControl { private System. ...

  5. Java 表达式解析(非原创)

    因项目需要,在网上找来一套表达式解析方法,由于原来的方法太过于零散,不利于移植,现在整理在同一文件内: 文件中包含5个内部类,源码如下: import java.util.ArrayList; imp ...

  6. Java Interface 是常量存放的最佳地点吗?(转帖学习,非原创)

    Java Interface 是常量存放的最佳地点吗?(转帖学习,非原创) 由于java interface中声明的字段在编译时会自动加上static final的修饰符,即声明为常量.因而inter ...

  7. 用RD,GR,BL三个方法内代码生成一张图片(非原创,我只是完整了代码)

    我公开以下图片的源代码,,是ppm格式的,,自己找到能打开的工具.. (非原创,我加工的代码,可直接执行运行输出,缩略图能看到效果)  这是原博客 http://news.cnblogs.com/n/ ...

  8. tp5.1 phpspreadsheet- 工具类 导入导出(整合优化,非原创,抄一抄,加了一些自己的东西,)

    phpspreadsheet-工具类 导入导出(整合优化,非原创,抄一抄,加了一些自己的东西)1. composer require phpoffice/phpspreadsheet2. 看最下面的两 ...

  9. Vue 仿QQ左滑删除功能(非原创)

    非原创,摘选来源:http://www.jb51.net/article/136221.htm. 废话不多说,相当实用,先记录. Html代码: <div class="contain ...

  10. 老男孩Django笔记(非原创)

    .WEB框架 MVC Model View Controller 数据库 模板文件 业务处理 MTV Model Template View 数据库 模板文件 业务处理 ############## ...

随机推荐

  1. Java高并发与多线程(三)-----线程的基本属性和主要方法

    今天,我们开始Java高并发与多线程的第三篇,线程的基本属性和主要方法. [属性] 编号(ID) 类型long 用于标识不同的线程,编号唯一,只存在java虚拟机的一次运行 名称(Name) 类型St ...

  2. 安装jdk-windows系统

    1. 明确需要安装的jdk版本,注意jdk存在小版本号,例如jdk1.7_51,如果不清楚小版本号的话建议安装最新版本的jdk: 2. 打开cmd命令窗口,输入java -version查看本机是否安 ...

  3. Cisco发现协议

    CDP Cisco Discovery Protocol: 思科发现协议 是一个提供关于直接相连的交换机.路由器和其它Cisco设备的综合信息的专有工具 CDP 能够发现直接相邻的设备而不管这些设备所 ...

  4. hook笔记②

  5. Maven 依赖机制

    概述 在 Maven 依赖机制的帮助下自动下载所有必需的依赖库,并保持版本升级.让我们看一个案例研究,以了解它是如何工作的.假设你想使用 Log4j 作为项目的日志.这里你要做什么? 传统方式 访问 ...

  6. loj10087

    Southwestern Europe 2002,题面可参考 POJ 1201. 给定 n 个闭区间 [a_i,b_i] 和 n 个整数c_i .你需要构造一个整数集合Z ,使得对于任意i (1< ...

  7. codevs 1344 模拟退火

    1344 线型网络  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamo   题目描述 Description 有 N ( <=20 ) 台 PC 放在机房内 ...

  8. Excel通配符

    数据科学交流群,群号:189158789 ,欢迎各位对数据科学感兴趣的小伙伴的加入!

  9. Vagrant基本知识、基本操作

    Vagrant基本知识.基本操作 一.介绍 二.安装Vagrant 三.安装到Windows 四.准备Boxes 五.基本操作 六.Vagrant常用命令 七.Vagrantfile 7.1 box ...

  10. .net core 和 WPF 开发升讯威在线客服与营销系统:使用线程安全的 BlockingCollection 实现高性能的数据处理

    本系列文章详细介绍使用 .net core 和 WPF 开发 升讯威在线客服与营销系统 的过程.本产品已经成熟稳定并投入商用. 在线演示环境:https://kf.shengxunwei.com 注意 ...