洛谷 P3467 [POI2008]PLA-Postering】的更多相关文章

P3467 [POI2008]PLA-Postering 题目描述 All the buildings in the east district of Byteburg were built in accordance with the old arbitecture: they stand next to each other with no spacing inbetween. Together they form a very long chain of buildings of dive…
[POI 2008&洛谷P3467]PLA-Postering Description Byteburg市东边的建筑都是以旧结构形式建造的:建筑互相紧挨着,之间没有空间.它们共同形成了一条长长的,从东向西延伸的建筑物链(建筑物的高度不一). Byteburg市的市长Byteasar,决定将这个建筑物链的一侧用海报覆盖住.并且想用最少的海报数量,海报是矩形的. 海报与海报之间不能重叠,但是可以相互挨着(即它们具有公共边),每一个海报都必须贴近墙并且建筑物链的整个一侧必须被覆盖(意思是:海报需要将一…
BZOJ原题链接 洛谷原题链接 若第\(i\)个点不是割点,那么只有这个点单独形成一个连通块,其它点依旧连通,则答案为\(2\times (n-1)\). 若第\(i\)个点是割点,那么去掉这个点相关的边就会形成\(3\)种构成的连通块: 由点\(i\)本身构成. 由点\(i\)的子树(搜索树中)形成若干个连通块. 由除点\(i\)及其子树的所有其它点构成一个连通块. 于是我们可以在用\(tarjan\)找割点的过程中计算搜索树中每棵子树的大小,并统计答案即可. #include<cstdio>…
题目描述 The first stage of train system reform (that has been described in the problem Railways of the third stage of 14th Polish OI. However, one needs not be familiar with that problem in order to solve this task.) has come to an end in Byteotia. The…
P3477 [POI2008]PER-Permutation 题目描述 Multiset is a mathematical object similar to a set, but each member of a multiset may have more than one membership. Just as with any set, the members of a multiset can be ordered in many ways. We call each such or…
P3478 [POI2008]STA-Station 题目描述 The first stage of train system reform (that has been described in the problem Railways of the third stage of 14th Polish OI. However, one needs not be familiar with that problem in order to solve this task.) has come…
P3469 [POI2008]BLO-Blockade https://www.luogu.org/problem/P3469 题目描述 There are exactly nn towns in Byteotia. Some towns are connected by bidirectional roads. There are no crossroads outside towns, though there may be bridges, tunnels and flyovers. Ea…
题目 割点模板题. 可以将图中的所有点分成两部分,一部分是去掉之后不影响图的连通性的点,一部分是去掉之后影响连通性的点,称其为割点. 然后分两种情况讨论,如果该点不是割点,则最终结果直接加上2*(n-1).如果是的话,就求子树的每块连通块大小. 一个点的子树可以分成两类:存在返祖边或不存在. 对于前者,割掉该点并不影响连通性,所以和祖先算作一个联通块: 对于后者,割掉该点将使得其变为独立的联通块,所以在搜索时顺便计算\(size\). 于是可以方便地算出后者的\(size\)之和sum,而前者总…
一道经典的割点例题,用size数组记录该子树有多少个节点,sum是这棵搜索树上有多少个节点,sum*(n-sum-1)是将点删掉后的数对数量. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #define maxn 1000010 using namespace std; typedef long long ll; inline int read() { ;…
题目链接 [洛谷传送门] 题解 很显然,当这个点不是割点的时候,答案是\(2*(n-1)\) 如果这个点是割点,那么答案就是两两被分开的联通分量之间求组合数. 代码 #include <bits/stdc++.h> #define ll long long using namespace std; const int N = 500005; struct edge { int to, nt; } E[N << 1]; int dfn[N], low[N], H[N], sz[N];…