http://codeforces.com/contest/566/problem/D D. Restructuring Company time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Even the most successful company can go through a crisis period when yo…
D. Restructuring Company Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/566/problem/D Description Even the most successful company can go through a crisis period when you have to make a hard decision — to restructure, disca…
题目链接: D. Restructuring Company time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Even the most successful company can go through a crisis period when you have to make a hard decision — to re…
题意:给定 3 种操作, 第一种 1 u v 把 u 和 v 合并 第二种 2 l r 把 l - r 这一段区间合并 第三种 3 u v 判断 u 和 v 是不是在同一集合中. 析:很容易知道是用并查集来做,但是如果单纯的用并查集,肯定是要超时的,所以要用链表,如果合并了,就把链表指向, 这样就搞定了这个题. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #i…
Restructuring Company Even the most successful company can go through a crisis period when you have to make a hard decision — to restructure, discard and merge departments, fire employees and do other unpleasant stuff. Let's consider the following mo…
题意:给定N,M,然后给出M组信息(u,v,l,r),表示u到v有[l,r]范围的通行证有效.问有多少种通行证可以使得1和N连通. 思路:和bzoj魔法森林有点像,LCT维护最小生成树. 开始和队友在想维护连通性,而不是维护树,这样好像会很麻烦. 队友yy了一个算法:用线段树模拟并查集维护连通性.(发现和标程有点像? 我的代码:LCT维护最小生成树. ...先给代码,后面补一下题解. #include<bits/stdc++.h> #define ll long long using nam…