Oleg the client and Igor the analyst are good friends. However, sometimes they argue over little things. Recently, they started a new company, but they are having trouble finding a name for the company. To settle this problem, they've decided to play…
Oleg the client and Igor the analyst are good friends. However, sometimes they argue over little things. Recently, they started a new company, but they are having trouble finding a name for the company. To settle this problem, they've decided to play…
http://codeforces.com/contest/794/problem/C Description Oleg the client and Igor the analyst are good friends. However, sometimes they argue over little things. Recently, they started a new company, but they are having trouble finding a name for the…
Codeforces 1041 E 构造题. 给出一种操作,对于一棵树,去掉它的一条边.那么这颗树被分成两个部分,两个部分的分别的最大值就是这次操作的答案. 现在给出一棵树所有操作的结果,问能不能构造这样一颗树,可以的话输出它. 反正就是看每个数出现了几次,然后形成一条链,从这个数开始,依次减小,链向N. 这样处理每个数,就行了. 中间一旦有冲突(不能形成链了),直接NO. #include <bits/stdc++.h> using namespace std; map<int,int…
Oleg the client and Igor the analyst are good friends. However, sometimes they argue over little things. Recently, they started a new company, but they are having trouble finding a name for the company. To settle this problem, they've decided to play…
[题目链接]:http://codeforces.com/contest/794/problem/C [题意] 有n个位置; 两个人; 每个人都有n个字符组成的集合s1,s2(可以有重复元素); 然后两人轮流从各自的集合中取出一个字符; 把它放在这n个位置中的任意一个位置; 其中一个人想要让这n个字符组成的字符串字典序尽量小; 另外一个人则想让他尽量大; 问你最后字符串会变成什么样 [题解] s1和s2是两个人的集合 可以先把s1升序排; 然后s2降序排; 设ls1,ls2分别为s1和s2最左的…
http://codeforces.com/contest/794/problem/C 题意:A,B两人各有长度为n的字符串,轮流向空字符串C中放字母,A尽可能让字符串字典序小,B尽可能让字符串字典序大,A,B都知道对方的情况:A先手. 首先,A要C的字典序大,B要C的字典序小,所以先贪心,A的按从小到大排序,B的按从大到小排序. 那么现在我们已经知道了A,B分别要选择放到C的字符. 接下来博弈: B的最大字符等于小于A的最小字符: A走:A一定要B放到前面,所以A尽可能放到后面,放哪个呢?当然…
http://codeforces.com/contest/794/problem/C 题意: 有两个人要为公司起名字,每个人手中都有n个字符,现在要取一个n个字符长度的公司名.两人轮流取名,每次选择一个字符,可以任意选择放在1~n还未放置字符的位置上,每个字符限用一次. 现在第一个人希望公司名字典序越小越好,而第二个人希望字典序越大越好.输出最后的公司名. 思路: 首先肯定是要排序的,第一个人肯定去用前面最小的几个,而第二个人肯定去用前面最大的几个. 轮到第一个人时,我们首先将他手中最小的字符…
题目链接:http://codeforces.com/contest/794/problem/C 题意:有两个人每个人都有一个长度为n的字符串,两人轮流拿出一个字符串,放在一个长度为n的字符串的指定位置中,第一个 人他想让最后组成的字符串尽可能小,另一个人想要字符串尽可能的大.他们互相知道各自手中有什么字符串,最后输出组成的 字符串 #include <iostream> #include <cstring> #include <string> #include <…
考虑两个人,先把各自的集合排个序,丢掉一半,因为比较劣的那一半一定用不到. 然后贪心地放,只有两种决策,要么把一个最优的放在开头,要么把一个最劣的放在结尾. 如果我的最优的比对方所有的都劣(或等于),我就把我最劣的往结尾放.否则我把我最优的往开头放. 用multiset维护两人的集合即可. #include<cstdio> #include<cstring> #include<algorithm> #include<set> using namespace…