There are n cities numbered from 1 to n in Berland. Some of them are connected by two-way roads. Each road has its own length — an integer number from 1 to 1000. It is known that from each city it is possible to get to any other city by existing road…
C. Roads in Berland time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are n cities numbered from 1 to n in Berland. Some of them are connected by two-way roads. Each road has its own l…
F - Roads in Berland Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 25C Description There are n cities numbered from 1 to n in Berland. Some of them are connected by two-way roads. Each…
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 用floyd思想. 求出来这条新加的边影响到的点对即可. 然后尝试更新点对之间的最短路就好. 更新之后把差值从答案里面减掉. [代码] #include <bits/stdc++.h> #define ll long long using namespace std; const int N = 300; int n; ll dis[N+10][N+10]; int k; ll ans = 0; void updata(ll &…
Description There are n cities numbered from 1 to n in Berland. Some of them are connected by two-way roads. Each road has its own length — an integer number from 1 to 1000. It is known that from each city it is possible to get to any other city by e…
题目链接: http://codeforces.com/problemset/problem/25/C 题意: 给一个最初的所有点与点之间的最短距离的矩阵.然后向图里加边,原有的边不变,问加边后的各个顶点的距离是多少. 思路: 这个一看就知道是folyd的变种,关键是状态转移怎么处理,具体看代码. 代码: #include<bits/stdc++.h> #define LL long long using namespace std; ; int dist[maxn][maxn]; LL an…
题目 题意: 有n种化学物质,第i种物质现有bi千克,需要ai千克.有n-1种,编号为2-n的转换方式,每种都为(x,k),第i行是编号为i+1的转换方式,编号为i的转换方式(xi,ki)表示ki千克的xi物质可以转换成1千克的i物质,1千克的i物质可以转换成1千克的xi物质.问是否可能通过转换得到足够的需要的物质.(1 ≤ xj + 1 ≤ j) 重点:上面标红的条件.如果只保留ki千克的xi物质可以转换成1千克的i物质产生的一条有向边,表明xi物质连出的边一定是指向编号大于i的物质的(x[i…
E. President and RoadsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/567/problem/E Description Berland has n cities, the capital is located in city s, and the historic home town of the President is in city t (s ≠ t). The c…
Description Berland has n cities, the capital is located in city s, and the historic home town of the President is in city t (s ≠ t). The cities are connected by one-way roads, the travel time for each of the road is a positive integer. Once a year t…
Berland has n cities, some of them are connected by bidirectional roads. For each road we know whether it is asphalted or not. The King of Berland Valera II wants to asphalt all roads of Berland, for that he gathered a group of workers. Every day Val…