2016 NEERC, Moscow Subregional Contest K. Knights of the Old Republic 题意:有一张图,第i个点被占领需要ai个兵,而每个兵传送至该点需要bi的费用.占领第i条边需要其两端点的兵数之和大等于ci.对于已占领的点或边可以免费通行.因此兵达到一个点的手段有传送和沿路走.图上的兵可以在已占领的点.边随意调度. 求占领所有点的最小花费. 思路:将边按ci进行升序排列,对于每条边两端点所在的连通块进行合并,合并细节见代码.这里有一点值得思…
A. Altitude 从小到大加入每个数,用set查找前驱和后继即可. 时间复杂度$O(n\log n)$. #include <bits/stdc++.h> using namespace std ; const int Maxn=100020,Inf=1e9; typedef pair<int,int>pi; int n; int a[Maxn]; vector<pi>V; set<int>S; int ans,rep1,rep2,rep3; int…
Problem K. KMC Attacks 题目连接: http://codeforces.com/gym/100714 Description Warrant VI is a remote planet located in the Koprulu Sector. Warrant VI features a strange huge field, which was discovered by the Kel-Morian Combine (KMC). The KMC is involved…
Problem D. Distance 题目连接: http://codeforces.com/gym/100714 Description In a large city a cellular network operator is holding a competition for subscribers to promote their new "pedestrian navigator" service. The main prize will be awarded to th…
E. Equal Digits time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output For the given integer N and digit D, find the minimal integer K ≥ 2 such that the representation of N in the positional nume…
A. Advanced 2048 time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Only lazy did not play the 2048 game last year. Soon, the secret of success had been revealed and interest to the game has…
比赛链接:http://codeforces.com/gym/100861 A模拟,注意两个特殊的缩写. #include <bits/stdc++.h> using namespace std; typedef pair<string, string> pss; const string MSU = "MSU"; const string SCH = "SCH"; ; map<string, int> school; int n…
A. Advertising Strategy 最优策略一定是第一天用$y$元,最后一天再用$x-y$元补满. 枚举所有可能的$y$,然后模拟即可,天数为$O(\log n)$级别. 时间复杂度$O(x\log n)$. #include<cstdio> typedef long long ll; const ll inf=1LL<<60; ll min(ll a,ll b){return a<b?a:b;} ll cal(ll n,ll x,ll o){ ll ans=1;…
题意:有n张照片,每张照片上有一些妹子,要按照片顺序给妹纸安排男朋友,如果妹纸i安排的男朋友之前有女朋友,那么费用+wi,求总费用最小,和输出路径 题解:费用流,先把照片天数建点i连i+1,流量k(最多的男朋友数量),费用0,再把所有按照片顺序出现的妹纸拆点,自己流自己,流量1,费用-inf(保证要安排上),假设当前妹纸是第i天出现的,如果该妹纸之前出现过,我们连一条上一次的到当前点,流量为1,费用0(表示沿用上一次的男朋友),否则从第1个照片点连一条流量为1,费用0的边(表示安排一个之前没有用…
Problem F. Finance 题目连接: http://codeforces.com/gym/100714 Description The Big Boss Company (BBC) principal is going to prepare a vacation schedule for the next year. Each employee of BBC gets a four-week vacation each year. A vacation can be divided…