CF1578J Just Kingdom】的更多相关文章

考虑一个点被填满则他需要从其父亲得到\(q_u = \sum_{v = u\ or\ v \in son_u}m_v\) 那么考虑如何这样操作. 我当时world final做的时候,是从上往下遍历,此时有若干分数流下下方,然后就疯狂的wa. 那么我们考虑从下往上做,考虑如何从儿子调整到父亲. 我们发现如果儿子有 \(x\) 这样的流,那么其他每个儿子都有 \(\min {(x,q_u)}\) 那么其有父亲有\(\sum \min{(x,q_u)}\)流下来. 接下来是比较有关键的trick.…
Constructing Roads In JGShining's Kingdom  HDU1025 题目主要理解要用LCS进行求解! 并且一般的求法会超时!!要用二分!!! 最后蛋疼的是输出格式的注意(直接报错误!!!) #include<iostream> #include<stdio.h> #include<algorithm> #include<string.h> using namespace std; ],dp[]; int main() { ,…
Kingdom Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 142    Accepted Submission(s): 84Special Judge Problem Description Teacher Mai has a kingdom consisting of n cities. He has planned the tr…
Description Meanwhile, the kingdom of K is getting ready for the marriage of the King's daughter. However, in order not to lose face in front of the relatives, the King should first finish reforms in his kingdom. As the King can not wait for his daug…
Rabbit Kingdom Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 40    Accepted Submission(s): 20 Problem Description Long long ago, there was an ancient rabbit kingdom in the forest. Every rabbit…
Constructing Roads In JGShining's Kingdom Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 14635    Accepted Submission(s): 4158 Problem Description JGShining's kingdom consists of 2n(n is no mo…
D. Dividing Kingdom II   Long time ago, there was a great kingdom and it was being ruled by The Great Arya and Pari The Great. These two had some problems about the numbers they like, so they decided to divide the great kingdom between themselves. Th…
Constructing Roads In JGShining's Kingdom Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 23467    Accepted Submission(s): 6710 Problem Description JGShining's kingdom consists of 2n(n is no mo…
Kingdom of Obsession Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Problem Description There is a kindom of obsession, so people in this kingdom do things very strictly. They name themselves in integer, and there…
Constructing Roads In JGShining's Kingdom Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 16047    Accepted Submission(s): 4580 Problem Description JGShining's kingdom consists of 2n(n is no mor…
Kingdom of Black and White Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5583 Description In the Kingdom of Black and White (KBW), there are two kinds of frogs: black frog and white frog. Now N frogs are stand…
Problem Description JGShining's kingdom consists of 2n(n is no more than 500,000) small cities which are located in two parallel lines. Half of these cities are rich in resource (we call them rich cities) while the others are short of resource (we ca…
Kingdom of Obsession Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 49    Accepted Submission(s): 14 Problem Description There is a kindom of obsession, so people in this kingdom do things very…
Problem Description JGShining's kingdom consists of 2n(n is no more than 500,000) small cities which are located in two parallel lines. Half of these cities are rich in resource (we call them rich cities) while the others are short of resource (we ca…
Constructing Roads In JGShining's Kingdom Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 21002    Accepted Submission(s): 5935 Problem Description JGShining's kingdom consists of 2n(n is no mor…
Problem Description In the Kingdom of Black and White (KBW), there are two kinds of frogs: black frog and white frog. Now N frogs are standing in a line, some of them are black, the others are white. The total strength of those frogs are calculated b…
题目链接:hdu 4778 Rabbit Kingdom 题目大意:Alice和Bob玩游戏,有一个炉子.能够将S个同样颜色的宝石换成一个魔法石.如今有B个包,每一个包里有若干个宝石,给出宝石的颜色.如今由Alice開始,两人轮流选取一个包的宝石放入炉中,每当获得一个魔法石时,能够额外获得一次机会再选一个包放入.两人均依照自己的最优策略.问说最后Alice的魔法石-Bob的魔法石是多少. 解题思路:状态压缩,221,对于每次移动到下一个状态,假设获得的魔法石g非零.则说明下一个状态还是自己在取.…
B. Help Kingdom of Far Far Away 2 time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output For some time the program of rounding numbers that had been developed by the Codeforces participants durin…
UVA1455 - Kingdom(并查集 + 线段树) 题目链接 题目大意:一个平面内,给你n个整数点,两种类型的操作:road x y 把city x 和city y连接起来,line fnum (浮点数小数点一定是0.5) 查询y = fnum这条直线穿过了多少个州和city.州指的是连通的城市. 解题思路:用并查集记录城市之间是否连通,还有每一个州的y的上下界.建立坐标y的线段树,然后每次运行road操作的时候,对范围内的y坐标进行更新:更新须要分三种情况:两个州是相离,还是相交,还是包…
HDU 4777 Rabbit Kingdom 题目链接 题意:给定一些序列.每次询问一个区间,求出这个区间和其它数字都互质的数的个数 #include <cstdio> #include <cstring> #include <algorithm> #include <vector> using namespace std; const int INF = 0x3f3f3f3f; typedef long long ll; const ll N = 200…
原题链接: Kingdom Division 由于树的层次可能很深,所以这里不能使用递归版的DFS.我使用了BFS. BFS确定各结点的父结点和它的孩子数. 用逆拓扑排序确定结点的计算顺序. same[u][] 表示u结点颜色为0孩子结点颜色全为1时组合数. diff[u][] 表示u结点颜色为0时可行组合数.本结点颜色为0,子结点颜色为1,孙结点颜色全为0是无效组合.反之亦然.由于这里颜色0.1相互对称, same[u][]=same[u][]; diff[u][]=diff[u][]; .…
Kingdom of Black and White Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 585    Accepted Submission(s): 193 Problem Description In the Kingdom of Black and White (KBW), there are two kinds of…
[CF613D]Kingdom and its Cities 题意:给你一棵树,每次询问给出k个关键点,问做多干掉多少个非关键点才能使得所有关键点两两不连通. $n,\sum k\le 10^5$ 题解:刷虚树板子啦! 首先如果两个关键点相邻则无解.然后建出虚树,进行树形DP.设f[i]表示i子树中的关键点都不连通,且i子树中的点与外面的点也不连通的最小花费,g[i]表示i子树重的关键点都不连通,且子树中只有一个点与外面的点连通的最小花费.转移时讨论一波即可. #include <cstdio>…
[CF687D]Dividing Kingdom II 题意:给你一张n个点m条边的无向图,边有边权$w_i$.有q个询问,每次给出l r,问你:如果只保留编号在[l,r]中的边,你需要将所有点分成两个集合,使得这个划分的代价最小,问最小代价是什么.一个划分的代价是指,对于所有两端点在同一集合中的边,这些边的边权最大值.如果没有端点在同一集合中的边,则输出-1. $n,q\le 1000,m\le \frac {n(n-1)} 2,w_i\le 10^9$ 题解:先考虑暴力的做法,我们将所有边按…
D. Dividing Kingdom II 题目连接: http://www.codeforces.com/contest/687/problem/D Description Long time ago, there was a great kingdom and it was being ruled by The Great Arya and Pari The Great. These two had some problems about the numbers they like, so…
[CF613D]Kingdom and its Cities 题面 洛谷 题解 看到关键点当然是建虚树啦. 设\(f[x]\)表示以\(x\)为根的子树的答案,\(g[x]\)表示以\(x\)为根的子树内是否有和\(x\)联通的点,\(c=\sum_{v\in son_x} g[v]\). 分类讨论一下: 如果一个点在原树下它和它的父亲均为关键点,那么显然不行. 这个点是关键点,\(f[x]+=c\),\(g[x]=1\) 这个点不是关键点,若\(c>1\)则断掉这个点,\(++f[x],g[x…
1130: [POI2008]POD Subdivision of Kingdom https://lydsy.com/JudgeOnline/problem.php?id=1130 分析: 有效状态为$C_{26}^{13}$,所以直接搜索就好了. 代码: #include<cstdio> #include<algorithm> #include<cstring> #include<iostream> #include<cmath> #incl…
大致题意: 给出一个凸包,以及凸包内的两个点p1,p2,求有多少条经过凸包顶点的直线能够将凸包分割为两部分,且给出的两点分别属于不同的部分 枚举凸包的顶点,二分求出p1,p2线段左边的最大坐标L以及右边的最小坐标R,则答案为R-L-1的累加和除以2 注意文件输入,输出 #include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #include<queue>…
\(>Codeforces\space835 F. Roads in the Kingdom<\) 题目大意 : 给你一棵 \(n\) 个点构成的树基环树,你需要删掉一条环边,使其变成一颗树,并最小化删掉环边后的树的直径. \(n \leq 2 \times 10^5\) 树的边权 $ \leq 10^9 $ 解题思路 : 考虑最终树的直径可能由两部分组成,答案是其中的最大值 第一种就是外向树内的直径的最大值,这个只需要随便\(dp\)一下即可,这里不过多讨论 第二种情况树的直径经过原来的环,…
[CF115E]Linear Kingdom Races 题目大意: 有\(n(n\le10^5)\)个物品,编号为\(1\sim n\).选取第\(i\)个物品需要\(c_i\)的代价.另外有\(m(m\le10^5)\)个条件,表示若\(l_i\sim r_i\)间的物品全部选择,可以获得\(p_i\)的收益.求最大收益. 思路: 用\(f[i]\)表示考虑完前\(i\)个物品是否选取能获得的最大收益. 转移方程为\(f[i]=\max\{f[j]-\texttt{cost}(j+1,i)+…