[CF1000E]We Need More Bosses】的更多相关文章

题意:无向联通图,求一条最长的路径,路径长度定义为u到v必须经过的边的个数 如果把强联通分量都缩成一个点以后,每个点内部的边都是可替代的:而又因为这是个无向图,缩完点以后就是棵树,跑两遍dfs求直径即可 #include<bits/stdc++.h> #define pa pair<int,int> #define CLR(a,x) memset(a,x,sizeof(a)) using namespace std; typedef long long ll; ; inline l…
题目大意:给一张无向图,要求找一对$s$和$t$,使得其路径上的割边是最多的,输出其数量. 题解:把边双缩点以后求树的直径. 卡点:无 C++ Code: #include <cstdio> #include <cstring> #define maxn 300010 #define maxm 300010 #define ONLINE_JUDGE #define read() R::READ() #include <cctype> namespace R { int…
这道题绝不是紫题... 题目的意思其实是让你求一个无向无重边图的直径. 对于求直径的问题我们以前研究过树的直径,可以两遍dfs或者两边bfs解决. 对于图显然不能这样解决,因为图上两点之间的简单路径不唯一. 那怎么解决这个问题呢? 能不能把环都搞掉呢? 于是乎,我们想到了强连通分量. 因此先用tarjan缩一下点,重新建图跑一个直径就可以解决这个问题了. AC代码如下: 3053ms 23816kb #include<bits/stdc++.h> using namespace std; na…
Your friend is developing a computer game. He has already decided how the game world should look like — it should consist of nn locations connected by mm two-way passages. The passages are designed in such a way that it should be possible to get from…
E - We Need More Bosses CodeForces - 1000E Your friend is developing a computer game. He has already decided how the game world should look like - it should consist of nn locations connected by mm two-waypassages. The passages are designed in such a…
题意: 就是求桥最多的一条路 解析: 先求连通分量的个数 然后缩点建图  求直径即可 #include <bits/stdc++.h> #define mem(a, b) memset(a, b, sizeof(a)) using namespace std; , INF = 0x7fffffff; vector<]; ], lowlink[maxn<<], sccno[maxn<<], dfs_clock, scc_cnt, d[maxn<<], v…
Many companies regularly look up job applicants online as part of the hiring process. A new study suggests they may also use what they find to discriminate. discriminate against:歧视,排斥 look up:查阅,仰望,拜访 The study, a Carnegie Mellon University experimen…
题面在这里! 依然一眼题,求出割边之后把图缩成一棵树,然后直接求最长链就行了2333 #include<bits/stdc++.h> #define ll long long using namespace std; #define pb push_back const int N=300005; vector<int> g[N]; int dfn[N],low[N],num=1,hd[N],n,m,ans=0,v[N]; int to[N*2],ne[N*2],cnt,col[N…
Bryce1010模板 http://codeforces.com/contest/1000/problem/E 题意: 给一个无向图,求图的最长直径. 思路:对无向图缩点以后,求图的最长直径 #include<bits/stdc++.h> #define ll long long using namespace std; const int maxn=600010; int From[maxn],Laxt[maxn],To[maxn<<2],Next[maxn<<2]…
大意: 给定无向连通图, 定义两个点$s,t$个价值为切断一条边可以使$s,t$不连通的边数. 求最大价值. 显然只有桥会产生贡献. 先对边双连通分量缩点建树, 然后求直径即为答案. #include <iostream> #include <cstdio> #include <queue> #define REP(i,a,n) for(int i=a;i<=n;++i) #define pb push_back using namespace std; cons…