Codeforces Round #228 (Div. 1) 题目链接:C. Fox and Card Game Fox Ciel is playing a card game with her friend Fox Jiro. There are n piles of cards on the table. And there is a positive integer on each card. The players take turns and Ciel takes the first…
刚刚看到这个题感觉是博弈题: 不过有感觉不像,应该是个贪心: 于是就想贪心策略: 举了一个例子: 3 3 1 2 3 4 3 4 1 2 5 4 1 2 5 8 如果他们两个每次都拿对自己最有利的那个的话,C的得分是14分: 但是C作为第一个选手,他有更好的策略,只拿前一半,后一半给J,中间的再分:这样的话C的得分就能达到15分: 同样J也有这样的策略,他也能保证自己最少能拿到后一半的分(跟风式的拿): 这样的话,贪心策略就明朗了! #include<cstdio> #include<c…
C. Fox and Card Game 题目连接: http://codeforces.com/contest/388/problem/C Description Fox Ciel is playing a card game with her friend Fox Jiro. There are n piles of cards on the table. And there is a positive integer on each card. The players take turns…
题目连接:Codeforces 437C  The Child and Toy 贪心,每条绳子都是须要割断的,那就先割断最大值相应的那部分周围的绳子. #include <iostream> #include <cstring> #include <cstdio> #include <algorithm> using namespace std; const int MAX_N = 1000 + 10; int G[MAX_N][MAX_N]; struct…
https://codeforces.com/contest/1136/problem/D 贪心 + 思维 题意 你面前有一个队列,加上你有n个人(n<=3e5),有m(m<=个交换法则,假如u在v相邻前面,那么u和v可以交换位置,问你是队列最后一个人的时候你最前可以换到前面哪里 题解 因为相邻才能换,所以最后一个换到前面一定是一步一步向前走,所以不存在还要向后走的情况 设最后一个为u,假设前面有一个能和u换位置的集合,那么需要将这些点尽量往后移动去接u 假设前面有一个不能和u换位置的集合S,…
[BZOJ4391][Usaco2015 dec]High Card Low Card(贪心) 题面 BZOJ 题解 预处理前缀后缀的结果,中间找个地方合并就好了. #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<algorithm> #include<set> using na…
题目链接:http://codeforces.com/problemset/problem/462/B Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards…
A. Fox and Box Accumulation 题目连接: http://codeforces.com/contest/388/problem/A Description Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top…
题意:给你一棵树,每次可以去掉叶节点的一条边,Ayush先开始,每回合轮流来,问谁可以第一个把\(x\)点去掉. 题解:首先如果\(x\)的入度为\(1\),就可以直接拿掉,还需要特判一下入度为\(0\)的情况,否则,仔细想一想,因为每次都不想让对方赢,所以摘到最后,一定会出现\(x\)连的都是叶结点的情况,所以此时我们只要判断一下总边数的奇偶就行了(相当于把所有的边都拿光). 代码: #include <iostream> #include <cstdio> #include &…
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尽可能放到后面,放哪个呢?当然…