[题目]C. Maximum Element [题意]给定n和k,定义一个排列是好的当且仅当存在一个位置i,满足对于所有的j=[1,i-1]&&[i+1,i+k]有a[i]>a[j],求长度为n的好的排列数.n<=10^6. [算法]排列组合+动态规划 [题解]设D(n)表示长度为n且满足a[n]=n的好的排列数,考虑这样的一个排列w. 如果数字n-1的位置j<n-k,那么显然这是一个好的排列. 如果数字n-1的位置j>=n-k,那么位置j前的数字一定<n-1…
D. Holidays Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/problem/D Description Everyone knows that the battle of Endor is just a myth fabled by George Lucas for promotion of his movie. Actually, no battle of Endor has…
Maximum Score Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=83008#problem/J Description Ron likes to play with integers. Recently he is interested in a game where some integers are given and he is…
C. Array time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Chris the Rabbit has been interested in arrays ever since he was a child. At the moment he is researching arrays with the length of…
[题目]H. Ember and Storm's Tree Game [题意]Zsnuoの博客 [算法]动态规划+排列组合 [题解]题目本身其实并不难,但是大量干扰因素让题目显得很神秘. 参考:Zsnuoの博客 一.首先Ember必胜(考虑n个点连成一条链),故合法的树一定满足先手必胜.当Storm选择的链满足单调或单峰时,每一条链对答案贡献两对(i,op). 解释:单调时,考虑翻转最后一个数和从第二个数开始取负两种操作.单峰时,上凸考虑翻转顶峰和顶峰右侧的数,下凸考虑取负顶峰和顶峰右侧的数.…
C. Kyoya and Colored Balls Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/554/problem/C Description Kyoya Ootori has a bag with n colored balls that are colored with k different colors. The colors are labeled from 1 to k.…
题目链接 Maximum Element 题意 现在有这一段求序列中最大值的程度片段: (假定序列是一个1-n的排列) int fast_max(int n, int a[]) { int ans = 0; int offset = 0; for (int i = 0; i < n; ++i) if (ans < a[i]) { ans = a[i]; offset = 0; } else { offset = offset + 1; if (offset == k) return ans…