题意: 给你两个01串,要你选n/2个位置,使得选的位置在s1中"1"的数量等于未选的s2中"1"的数量 n<=5000,1s 思路: 设两个串中出现"00""01""10""11"的总数是A,B,C,D,我们选的个数分别是a,b,c,d 数据最多能承受n^2的暴力 根据题意,有a+b+c+d=n/2     ① c+d=B-b+D-d    ② 联立得d=B+D+a-n/2 于是…
构造模拟要分情况讨论感觉不是够本质,然后官解是因为只有四个量所以可以根据限制条件列两个方程,再枚举一下解就可以了. const int maxn = 5000 + 5; int n, c[maxn], a[maxn]; vector<int> zero, two, cl, ac, ans1, ans2; int main() { cin >> n; getchar(); rep(i, 1, n) { char ch = getchar(); c[i] = ch - '0'; } g…
Codeforces 1041 E 构造题. 给出一种操作,对于一棵树,去掉它的一条边.那么这颗树被分成两个部分,两个部分的分别的最大值就是这次操作的答案. 现在给出一棵树所有操作的结果,问能不能构造这样一颗树,可以的话输出它. 反正就是看每个数出现了几次,然后形成一条链,从这个数开始,依次减小,链向N. 这样处理每个数,就行了. 中间一旦有冲突(不能形成链了),直接NO. #include <bits/stdc++.h> using namespace std; map<int,int…
A B C 题目给你一个结论 最少需要min((odd,even)个结点可以把一棵树的全部边连起来 要求你输出两颗树 一棵树结论是正确的 另外一棵结论是正确的 正确结论的树很好造 主要是错误的树 题目给了你提示 提供了一个八个结点的错误的树 然后我们慢慢推发现只要N>=6就存在错误的树(把提供的树的左边两个结点删掉) 结点大于6就全部放在4号结点下 #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset…
Hidden Code 题目连接: http://codeforces.com/gym/100015/attachments Description It's time to put your hacking skills to the test! You've been called upon to help crack enemy codes in the current war on... something or another. Anyway, the point is that yo…
A. ArielTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/A Description King Triton really likes watching sport competitions on TV. But much more Triton likes watching live competitions. So Triton decides to set up…
G. #TheDress Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100637/problem/G Description After landing on planet i1c5l people noticed that blue and black clothes are quite popular among the locals. Each aboriginal has at least…
Couple Cover Time Limit: 3000MS   Memory Limit: 524288KB   64bit IO Format: %I64d & %I64u Description 方宝宝有n个篮球,每个篮球上写有一个值ai.他第一次从n个篮球中取出1个,不放回.第二次再在剩余的篮球中取出一个. (每个球被取概率相同).如果这两个球上的值的乘积大于等于p,他会变得高兴,然后请大家吃饭.否则方宝宝会不高兴, 然后暴食暴饮变得更胖. 当然为了方宝宝的健康(被请吃饭),我想取一个…
D. Jerry's Protest time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Andrew and Jerry are playing a game with Harry as the scorekeeper. The game consists of three rounds. In each round, Andr…
http://codeforces.com/contest/1004/problem/D 题意:网格图给定到中心点的曼哈顿距离数组, 求该图n,m及中心点位置 首先可以观察到距离最大值mx一定在某个角上, 可将它调整到位置(n,m) 设中心点(x, y) 则可以得到 n-x+m-y=mx 再注意到假若图无限大, 则对每个距离d的取值一定有4*d个 即第一个取值数<4*d的d可以调整为中心点的x坐标 然后就可以暴力枚举因子判断了 #include <iostream>#include &l…