链接 奇怪的构造题。。。首先考虑 \(n\) 是奇数的情况。可以发现由于每个非主对角线上的点都会匹配上两行,所以每个数都需要一个对角线上的点。显然不可行。 考虑 \(n\) 为偶数的情况。这里给出一种构造。 首先,为了方便,我们将主对角线上填上1。可以发现,假如我们用 $2~n$ 填好了下三角部分, ...
分类:
其他好文 时间:
2020-07-12 16:50:44
阅读次数:
43
Permutation Sequence (M) 题目 The set [1,2,3,...,*n*] contains a total of n! unique permutations. By listing and labeling all of the permutations in ord ...
分类:
其他好文 时间:
2020-07-07 10:12:57
阅读次数:
64
package LeetCode_31 /** * 31. Next Permutation * https://leetcode.com/problems/next-permutation/description/ * Implement next permutation, which rearr ...
分类:
其他好文 时间:
2020-06-28 18:53:29
阅读次数:
51
链接:https://leetcode-cn.com/problems/next-permutation/ 代码 class Solution { public: void nextPermutation(vector<int>& nums) { int k = nums.size() - 1; w ...
分类:
其他好文 时间:
2020-06-25 23:30:17
阅读次数:
53
Next Permutation (M) 题目 Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such a ...
分类:
其他好文 时间:
2020-06-25 09:57:33
阅读次数:
51
max()/min()/abs()函数 swap()函数 reverse()函数 next_permutation()函数 fill()函数 sort()函数 头文件需要 #include<algorithm> using namespace std 使用方法 sort(首元素地址(必填), 尾元素 ...
分类:
其他好文 时间:
2020-06-23 21:43:03
阅读次数:
58
The set [1,2,3,...,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order, we get the following seque ...
分类:
其他好文 时间:
2020-06-21 10:13:55
阅读次数:
48
$zay$讲的题 luogu P6599 异或 luogu CF1352G Special Permutation luogu CF1360F Spy-string luogu P6599 异或 题目描述 有 \(T\) 组询问,每次给定两个正整数 \(n,l\)。 你需要构造一个长度为 \(l\) ...
分类:
其他好文 时间:
2020-06-14 16:52:53
阅读次数:
71
其实和八皇后的算法差不多,八皇后不检查斜线的结果就是全排列,此外八皇后中检查皇后位置麻烦,这里只要把列表转成词典,检查一下长度就行了(有重复元素,比如到第二层,应该是1,2,如果是1,1,那么词典长度就只有1了,需要排除): def permutation(n,floor,per): for pos ...
分类:
编程语言 时间:
2020-06-12 12:48:38
阅读次数:
120
看题解之前,希望大家先自己列张表,会发现规律哦~ 用递归 #include<bits/stdc++.h>//万能头文件 using namespace std; int a[100005];//保存答案,当然你也可以直接输出(假如你能做到的话) int hhh(int N,int K) { if(N ...
分类:
其他好文 时间:
2020-06-11 20:03:28
阅读次数:
51