【刷题】洛谷 P3573 [POI2014]RAJ-Rally】的更多相关文章

P3573 [POI2014]RAJ-Rally 题意: 给定一个\(N\)个点\(M\)条边的有向无环图,每条边长度都是\(1\). 请找到一个点,使得删掉这个点后剩余的图中的最长路径最短. 输入输出格式 输入格式: 第一行包含两个正整数\(N\),\(M\),表示点数.边数. 接下来\(M\)行每行包含两个正整数\(A_i,B_i\),表示\(A_i\)到\(B_i\)有一条边. 输出格式: 包含一行两个整数\(x,y\),用一个空格隔开,\(x\)为要删去的点,\(y\)为删除x$后图中的…
题目描述 An annual bicycle rally will soon begin in Byteburg. The bikers of Byteburg are natural long distance cyclists. Local representatives of motorcyclists, long feuding the cyclists, have decided to sabotage the event. There are intersections in Byt…
Description 同OJ3522 数据范围:n<=100000 Solution dp的设计见[刷题]BZOJ 3522 [Poi2014]Hotel 然后发现dp的第二维与深度有关,于是长链剖分就可以优化成 \(O(n)\) 的了 不会写指针,所以写deque #include<bits/stdc++.h> #define ui unsigned int #define ll long long #define db double #define ld long double #…
洛谷题面传送门 考虑一个平凡的 DP:我们设 \(dp_i\) 表示前 \(i\) 辆车一来一回所需的最小时间. 注意到我们每次肯定会让某一段连续的火车一趟过去又一趟回来,故转移可以枚举上一段结束位置,设为 \(j\),那么有转移 \[dp_i=\min\limits_{j}\{\max(dp_j+i-j-1,a_i)+2s+i-j-1\} \] 在这里我们不妨假设 \(a_i<a_{i+1}\),这个可以通过从左到右扫一遍并执行 \(a_i\leftarrow\max(a_{i-1}+1,a_…
题目:https://www.luogu.org/problemnew/show/P4660 https://www.lydsy.com/JudgeOnline/problem.php?id=1168 自己一开始有这样的想法:枚举一边的手套一定选到 S 集合,设 c = 选到 S 里每个手套的最小需要选的手套个数,则 c = 这边所有手套个数 - (S里个数最小的手套个数-1) . 设 ts = 另一边一定选到 S 集合里的至少一个手套的最小需要选的手套个数,则 ts = 不在 S 集合里的手套…
P3576 [POI2014]MRO-Ant colony 题目描述 The ants are scavenging an abandoned ant hill in search of food. The ant hill has nn chambers and n-1n−1 corridors connecting them. We know that each chamber can be reached via a unique path from every other chamber…
题目传送门 MRO-Ant colony 题目描述 The ants are scavenging an abandoned ant hill in search of food. The ant hill has nn chambers and n-1n−1 corridors connecting them. We know that each chamber can be reached via a unique path from every other chamber. In othe…
题意:给一个数列,每次询问一个区间内有没有一个数出现次数超过一半 题解: 最近比赛太多,都没时间切水题了,刚好日推了道主席树裸题,就写了一下 然后 WA80 WA80 WA0 WA90 WA80 ?????? 结果重新审题发现没有数据范围???? 哦,原来是500000,我是真的菜 因为必须要一个数出现超过一半 所以这个数肯定会在左子树和右子树中总个数和较大的那个里. 显然这样二分找到树底复杂度是logn的 如果此时树底这个点的数值大于一半,那么就输出这个解,否则puts("0") 以…
大爷的字符串题 思路: 莫队,需开O2,不开50: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 200005 int bel[maxn],blo; struct QueryType { int l,r,id; bool operator<(const QueryType pos)const { if(bel[l]==bel[pos.l]) return r<pos.r; else return bel…
P3572 [POI2014]PTA-Little Bird 题目描述 In the Byteotian Line Forest there are nn trees in a row. On top of the first one, there is a little bird who would like to fly over to the top of the last tree. Being in fact very little, the bird might lack the s…