这题的思路跟这题差不多 设 f[i][j][0/1][0/1] 到第 i 位,有至少 j 个位置满足条件且数字 i 有 / 没有用过,数字 i + 1 有 / 没有用过 每次转移的时候就选择是否是这个位置满足条件 让他满足条件的话就从之前的没有填过 i - 1 的状态转移过来 让他不满足条件就填上一 ...
分类:
其他好文 时间:
2018-11-02 23:37:19
阅读次数:
191
题意,给定n,k,求有多少排列是的 | p[i]-i |=1 的数量为k。 Solution 直接dp会有很大的后效性。 所以我们考虑固定k个数字使得它们是合法的,所以我们设dp[i][j][0/1][0/1]表示前i个数,填了j个数,当前位置有没有被选,下一位有没有被选,这样做的话,转移会比较简单 ...
分类:
其他好文 时间:
2018-11-02 16:39:30
阅读次数:
204
挺有收获的一道题ヾ(?°?°?)?? 恰好为 m ,这个限制仿佛不是很好处理。一般而言,我所了解的恰好为 k 的条件,不是用组合数 / dp状态转移 / 斜率二分就只剩下容斥了。我们可以先处理出 num[i] 表示至少有 i 个完美位置的方案数,之后再容斥得到 ans[m] (恰好为 m 个)。如何 ...
分类:
其他好文 时间:
2018-10-29 00:35:04
阅读次数:
200
On an infinite number line (x-axis), we drop given squares in the order they are given. The i-th square dropped (positions[i] = (left, side_length)) i ...
分类:
其他好文 时间:
2018-10-04 16:02:28
阅读次数:
158
Given the radius and x-y positions of the center of a circle, write a function randPoint which generates a uniform random point in the circle. Note: E ...
分类:
其他好文 时间:
2018-10-04 11:40:39
阅读次数:
196
The Hamming distance between two integers is the number of positions at which the corresponding bits are different.Given two integers x and y, calcula ...
分类:
其他好文 时间:
2018-10-02 17:34:25
阅读次数:
156
In a string S of lowercase letters, these letters form consecutive groups of the same character. For example, a string like S = "abbxxxxzyy" has the g ...
分类:
编程语言 时间:
2018-09-30 12:54:23
阅读次数:
247
The task of this problem is simple: insert a sequence of distinct positive integers into a hash table, and output the positions of the input numbers. ...
分类:
其他好文 时间:
2018-09-22 14:28:41
阅读次数:
271
题目:http://codeforces.com/contest/285/problem/E 是2018.7.31的一场考试的题,当时没做出来。 题解:http://www.cnblogs.com/yanshannan/p/9410986.html 因为那个值对于 i 位置来说只和 i 位置放了 i ...
分类:
其他好文 时间:
2018-09-15 20:51:55
阅读次数:
296
The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, calcul ...
分类:
其他好文 时间:
2018-09-11 16:21:02
阅读次数:
184