Codeforces 449B_Jzzhu and Cities】的更多相关文章

给一个无向图,外加一些特殊的连接原点的无向边.在不改变原点与所有点的最短路的情况下,最多可以删除多少条特殊边? 首先我们把所有的边夹杂在一起.spfa跑出与所有点的最短路. 接下来我们通过一次bfs来判断哪些特殊的边是可以删除的.这里面的原理跟迪杰斯特拉算法差不多. 首先把原点加入队列,所有的特殊边按照长度排序,然后一直沿着非特殊边和最短的路径增广,把满足最短路条件的点都拉到队列里面来,直到队列元素为空,然后判断特殊边的最短的那一条边是否关键边,是的话就把它所连接的那个点拉到队列里面来.程序一直…
http://codeforces.com/contest/962/problem/E E. Byteland, Berland and Disputed Cities time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The cities of Byteland and Berland are located on the a…
A. Buses Between Cities time limit per test: 1 second memory  limit per test: 256 megabytes input: standard input output: standard output Buses run between the cities A and B, the first one is at 05:00 AM and the last one departs not later than at 11…
A. Buses Between Cities 题目连接: http://www.codeforces.com/contest/665/problem/A Description Buses run between the cities A and B, the first one is at 05:00 AM and the last one departs not later than at 11:59 PM. A bus from the city A departs every a mi…
题目描述: Jzzhu and Cities time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Jzzhu is the president of country A. There are n cities numbered from 1 to n in his country. City 1 is the capital of…
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…
D. Jzzhu and Cities time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Jzzhu is the president of country A. There are n cities numbered from 1 to n in his country. City 1 is the capital of A.…
Description There are n cities in Berland. Some pairs of them are connected with m directed roads. One can use only these roads to move from one city to another. There are no roads that connect a city to itself. For each pair of cities (x, y) there i…
Trucks and Cities 一个很显然的做法就是二分然后对于每个车贪心取check, 这肯定会TLE, 感觉会给人一种贪心去写的误导... 感觉有这个误导之后很难往dp那个方向靠.. dp[ k ][ i ][ j ]表示把 i, j 这个区间分成 k 段, 所有段的最大值的最小值为多少. 然后dp的过程中把车代进去求答案. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #…
题目链接:http://codeforces.com/contest/613/problem/D 题意概述: 给出一棵树,每次询问一些点,计算最少删除几个点可以让询问的点两两不连通,无解输出-1.保证询问的点总数不大于300000. 分析: 先考虑遍历的做法,统计每个点代表的子树中联通询问点的数量. 这个点不是询问点:如果有至少两个不同的子树中有询问点那么当前点一定被删除,因为这个时候不删除之后这两个点就是联通的:同时除了在更深的地方遇见第一种情况之外没有必要删除那些点:没有点不用管,只有一个点…