思路: http://codeforces.com/blog/entry/58869. 实现: #include <bits/stdc++.h> using namespace std; typedef long long ll; ; int t[MAXN], n; char c[MAXN]; int get_sum(int i, vector<int> & v, char color) { , last = v[i]; ; j <= v[i + ]; j++) {…
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…
E. Byteland, Berland and Disputed Cities time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output The cities of Byteland and Berland are located on the axis Ox. In addition, on this axis there are also…
Portal! ---> 几句话题意 数轴上面有三种点(B点,R点,P点),现在要将其中的某些点连起来,满足将所有B点去掉之后,所有P点和R点都连通&将所有R点去掉之后,所有B点和P点都连通两个条件,连接两点的代价为数轴上距离,求最小代价(读入按照数轴上位置从小到大的顺序) Solution 这题..其实是个特别神秘的贪心 首先有个特别直接的想法,就是..所有的B点和它的前一个B点或者P点连,所有的R点和它的前一个R点或者P点连,P点和前一个R点和前一个B点连,这样就一定能保证满足那两个条件…
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…
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…
E. New Reform time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Berland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities is connecte…
Codeforces Round #346 (Div. 2)---E. New Reform E. New Reform time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Berland has n cities connected by m bidirectional roads. No road connects a city…
They say that Berland has exactly two problems, fools and roads. Besides, Berland has n cities, populated by the fools and connected by the roads. All Berland roads are bidirectional. As there are many fools in Berland, between each pair of cities th…
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…