[HIHO1184]连通性二·边的双连通分量(双连通分量)
题目链接:http://hihocoder.com/problemset/problem/1184
题意裸,写个博客记下输出姿势。
- /*
- ━━━━━┒ギリギリ♂ eye!
- ┓┏┓┏┓┃キリキリ♂ mind!
- ┛┗┛┗┛┃\○/
- ┓┏┓┏┓┃ /
- ┛┗┛┗┛┃ノ)
- ┓┏┓┏┓┃
- ┛┗┛┗┛┃
- ┓┏┓┏┓┃
- ┛┗┛┗┛┃
- ┓┏┓┏┓┃
- ┛┗┛┗┛┃
- ┓┏┓┏┓┃
- ┃┃┃┃┃┃
- ┻┻┻┻┻┻
- */
- #include <algorithm>
- #include <iostream>
- #include <iomanip>
- #include <cstring>
- #include <climits>
- #include <complex>
- #include <fstream>
- #include <cassert>
- #include <cstdio>
- #include <bitset>
- #include <vector>
- #include <deque>
- #include <queue>
- #include <stack>
- #include <ctime>
- #include <set>
- #include <map>
- #include <cmath>
- using namespace std;
- #define fr first
- #define sc second
- #define cl clear
- #define BUG puts("here!!!")
- #define W(a) while(a--)
- #define pb(a) push_back(a)
- #define Rint(a) scanf("%d", &a)
- #define Rll(a) scanf("%lld", &a)
- #define Rs(a) scanf("%s", a)
- #define Cin(a) cin >> a
- #define FRead() freopen("in", "r", stdin)
- #define FWrite() freopen("out", "w", stdout)
- #define Rep(i, len) for(int i = 0; i < (len); i++)
- #define For(i, a, len) for(int i = (a); i < (len); i++)
- #define Cls(a) memset((a), 0, sizeof(a))
- #define Clr(a, x) memset((a), (x), sizeof(a))
- #define Full(a) memset((a), 0x7f7f, sizeof(a))
- #define lrt rt << 1
- #define rrt rt << 1 | 1
- #define pi 3.14159265359
- #define RT return
- #define lowbit(x) x & (-x)
- #define onenum(x) __builtin_popcount(x)
- typedef long long LL;
- typedef long double LD;
- typedef unsigned long long ULL;
- typedef pair<int, int> pii;
- typedef pair<string, int> psi;
- typedef pair<LL, LL> pll;
- typedef map<string, int> msi;
- typedef vector<int> vi;
- typedef vector<LL> vl;
- typedef vector<vl> vvl;
- typedef vector<bool> vb;
- const int maxn = ;
- const int maxm = ;
- typedef struct Edge {
- int u, v;
- int next, i;
- bool cut;
- Edge() {}
- Edge(int uu, int vv, int ii) : u(uu), v(vv), i(ii) {}
- }Edge;
- Edge edge[maxm];
- int head[maxn], ecnt;
- int n, m;
- int dfn[maxn];
- int low[maxn];
- bool vis[maxn];
- bool cut[maxn];
- vi bridge;
- int st[maxn], top;
- int belong[maxn], bcnt;
- vi tmp;
- int ret;
- void init() {
- Clr(head, -); Cls(low); Cls(dfn);
- Cls(vis); Cls(cut); Cls(st); ret = ;
- bcnt = ; top = ; ecnt = ; bridge.cl();
- }
- void adde(int uu, int vv, int ii) {
- edge[ecnt] = Edge(uu, vv, ii);
- edge[ecnt].cut = ;
- edge[ecnt].next = head[uu];
- head[uu] = ecnt++;
- }
- void tarjan(int u, int d, int p) {
- low[u] = dfn[u] = d;
- st[++top] = u;
- vis[u] = ;
- for(int i = head[u]; ~i; i=edge[i].next) {
- int v = edge[i].v;
- int id = edge[i].i;
- if(p == id) continue;
- if(!dfn[v]) {
- tarjan(v, d+, id);
- low[u] = min(low[u], low[v]);
- if(low[v] > dfn[u]) {
- bridge.pb(i);
- edge[i].cut = edge[i^].cut = ;
- }
- }
- else low[u] = min(low[u], dfn[v]);
- }
- if(low[u] == dfn[u]) {
- tmp.cl();
- int v;
- bcnt = 0x7f7f7f;
- do {
- v = st[top--];
- vis[v] = ;
- bcnt = min(bcnt, v);
- tmp.pb(v);
- }while(v != u);
- Rep(i, tmp.size()) belong[tmp[i]] = bcnt;
- ret++;
- }
- }
- int main() {
- // FRead();
- int u, v;
- while(~scanf("%d%d", &n, &m)) {
- init();
- For(i, , m+) {
- Rint(u); Rint(v);
- adde(u, v, i);
- adde(v, u, i);
- }
- For(i, , n+) {
- if(!dfn[i]) tarjan(i, , -);
- }
- printf("%d\n", ret);
- For(i, , n+) printf("%d ", belong[i]);
- printf("\n");
- }
- RT ;
- }
[HIHO1184]连通性二·边的双连通分量(双连通分量)的更多相关文章
- hihoCoder 1184 连通性二·边的双连通分量
#1184 : 连通性二·边的双连通分量 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 在基本的网络搭建完成后,学校为了方便管理还需要对所有的服务器进行编组,网络所的老 ...
- hihoCoder #1184 : 连通性二·边的双连通分量(边的双连通分量模板)
#1184 : 连通性二·边的双连通分量 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 在基本的网络搭建完成后,学校为了方便管理还需要对所有的服务器进行编组,网络所的老 ...
- HohoCoder 1184 : 连通性二·边的双连通分量(+原理证明)
1184 : 连通性二·边的双连通分量 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 在基本的网络搭建完成后,学校为了方便管理还需要对所有的服务器进行编组,网络所的老师 ...
- 高可用Mysql架构_Mysql主从复制、Mysql双主热备、Mysql双主双从、Mysql读写分离(Mycat中间件)、Mysql分库分表架构(Mycat中间件)的演变
[Mysql主从复制]解决的问题数据分布:比如一共150台机器,分别往电信.网通.移动各放50台,这样无论在哪个网络访问都很快.其次按照地域,比如国内国外,北方南方,这样地域性访问解决了.负载均衡:M ...
- 高可用Mysql架构_Mycat集群部署(HAProxy + 两台Mycat+Mysql双主双从)
既然大家都知道了Mysql分布式在大型网站架构中的作用,在这里就不再阐述.本片博客文章是基于我曾经搭建过的一个Mysql集群基础上实现的,实现过双主热备.读写分离.分库分表. 博客链接:http:// ...
- windows2003服务器双线双IP双网卡设置方法
双线双ip很好,网通用户访问网通线路,电信用户访问电信线路.但很多人会选用导入静态路由表,这个办法看似完美,其实问题很多. 1.电信用户如果被解析到网通的ip上,服务器根据路由表会返回电信线路,但用户 ...
- Windows 10、Ubuntu 18.04 双系统 双硬盘 安装经验总结
首先说明,我假设读者懂得分区.安装系统,所以不再深入讨论具体操作. 如果需要手把手教程,建议先参考其它Windows中加装Linux的相关文章. 网上其它文章.教程的常见问题是,各家机器配置不一样,安 ...
- 基于双XCKU060+双C6678 的双FMC接口40G光纤传输加速计算卡
基于双XCKU060+双C6678 的双FMC接口40G光纤传输加速计算卡 一.板卡概述 板卡采用基于双FPGA+双DSP的信号采集综合处理硬件平台,板卡大小360mmx217mm.板卡两片FPGA提 ...
- 基于双XCKU060+双C6678 的双FMC接口40G光纤传输加速计算卡381
一.板卡概述 板卡采用基于双FPGA+双DSP的信号采集综合处理硬件平台,板卡大小360mmx217mm.板卡两片FPGA提供两个FMC接口,4路QSFP+接口:每片FPGA挂接2簇32-bit DD ...
随机推荐
- 将eclipse的应用程序打包成.exe
转自:http://blog.163.com/loveshijie_1991/blog/static/1760553112012102573437156/ 参考:http://blog.csdn.ne ...
- c#之反射总结
1.了解什么事程序集 2.加载程序集 首先要加载需要加载的程序集,然后找到指定的类型,进而往下进行动态加载. 要加载的程序集中的内容: public class Class1:Person { pr ...
- Video Toolbox:读写解码回调函数CVImageBufferRef的YUV图像
本文档基于H.264的解码,介绍读写Video Toolbox解码回调函数参数CVImageBufferRef中的YUV或RGB数据的方法,并给出CVImageBufferRef生成灰度图代码.方便调 ...
- Android keyevent 中的各个值
Android keyevent 中的各个值,在使用adb shell input 的时候用得到. 是从http://blog.csdn.net/huiguixian/article/details/ ...
- Text Template Transformation Toolkit
Text Template Transformation Toolkit 1.且算简介 笔者以一个英文字母和一个数字取了一个简单的名字.名唤"T4"(名 ...
- 在ubuntu16.04 下安装haproxy 1.5.11 做tcp负载均衡
由于haproxy需要FQ下载,所以从csdn下载了较为新版的haproxy1.5.11,安装过程如下: 1. 解压haproxy-1.5.11.tar.gz : tar xzvf haproxy-1 ...
- BAT CMD 批处理文件脚本 -2
http://checheng1988.blog.51cto.com/4725808/1090733 在很多windows程序中会见到很多用扩展名为.bat和.cmd结尾的文件,那么这些文件能干什么呢 ...
- c++ uuid生成法则
http://www.jb51.net/LINUXjishu/39614.html CentOS #include <uuid/uuid.h> 找不到文件解决方法: sudo yum in ...
- IntelliJ IDEA的Maven项目在修改时报java.lang.OutOfMemoryError: PermGen space异常
什么也不说了---内存溢出,遇见太多回了,下面是解决方式: 1.在项目设置中新建Maven,然后设置VM: 2. 在pom.xml添加下面2个插件,一个是jrebel的,一个是jetty的 <b ...
- vc终端输入结束符
操作系统使用不同的值作为文件结束符.Windows上我们通过键入ctrl+z键作为文件结束符.Unix系统中,包括Mac OS-X机器,通常用ctrl+d作为文件结束符.用VC++6.0的时候,要输入 ...