题目描述: 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…
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\)…
CF449B CF450D http://codeforces.com/contest/450/problem/D http://codeforces.com/contest/449/problem/B Codeforces Round #257 (Div. 2) D Codeforces Round #257 (Div. 1) B D. Jzzhu and Cities time limit per test 2 seconds memory limit per test 256 megaby…
[题目链接] https://codeforces.com/contest/449/problem/B [算法] 最短路 时间复杂度 : O(N ^ 2) [代码] #include<bits/stdc++.h> using namespace std; ; const int INF = 2e9; int n , m , k; int mark[MAXN]; long long dist[MAXN]; bool inq[MAXN]; vector< pair<int,int>…
输入一个无向图<V,E>    V<=1e5, E<=3e5 现在另外给k条边(u=1,v=s[k],w=y[k]) 问在不影响从结点1出发到所有结点的最短路的前提下,最多可以删除k条边的多少条 跑最短路的时候维护或者统计就好了 一开始用spfa.然后TLE 45...好久没写  Dij+堆优化   ... p.s.优先队列默认大顶堆 Dij+堆优化   264ms #include <cstdio> #include <cstring> #include…
#include<bits/stdc++.h> #define MAXN 100050 #define MAXM 900000 using namespace std; struct st { int id; long long dis; st(int a,long long b) { id=a; dis=b; } st(){}; }; struct edge{ bool im; int id; long long w; edge *next; }; edge *adj[MAXN]; edge…
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.…
CF449B Jzzhu and Cities 其实这一道题并不是很难,只是一个最短路而已,请继续看我的题解吧~(^▽^) AC代码: #include<bits/stdc++.h> #define maxn 3000005 #define pa pair<long long,long long> #define inf 1000000000000000000ll using namespace std; long long n,m,k; struct edge{ long lon…
堆优化dijkstra,假设哪条铁路能够被更新,就把相应铁路删除. B. 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 co…
Dijkstra最短路算法 --转自啊哈磊[坐在马桶上看算法]算法7:Dijkstra最短路算法 上节我们介绍了神奇的只有五行的Floyd最短路算法,它可以方便的求得任意两点的最短路径,这称为“多源最短路”.本周来来介绍指定一个点(源点)到其余各个顶点的最短路径,也叫做“单源最短路径”.例如求下图中的1号顶点到2.3.4.5.6号顶点的最短路径. 与Floyd-Warshall算法一样这里仍然使用二维数组e来存储顶点之间边的关系,初始值如下. 我们还需要用一个一维数组dis来存储1号顶点到其余各…