逆序对目前我所知的有三种解法 首先是最简单的冒泡排序,当每次前面一个数比后面一个数大时就会交换,因此可以用冒泡排序来求逆序对 代码: #include<bits/stdc++.h> using namespace std; int main(){ int n,sum=0; cin>>n; int a ...
分类:
其他好文 时间:
2020-07-14 21:51:19
阅读次数:
65
该算法学习来自 b站 示例代码 1 输出的访问顺序与输入相反 #include <bits/stdc++.h> #define LL long long #define Pi acos(-1.0) #define INF 2147483646 #define eps 1e-9 #define MS ...
分类:
其他好文 时间:
2020-07-14 21:49:52
阅读次数:
72
二分图最大匹配: 匈牙利算法 邻接表O(mn): #pragma GCC optimize(2) #include <bits/stdc++.h> using namespace std; const int maxn = 1010; const int maxm = 2e5; int n, m, ...
分类:
其他好文 时间:
2020-07-14 21:42:51
阅读次数:
67
string.gsub(mainString,findString,replaceString,num) 在字符串中替换 mainString 为要操作的字符串, findString 为被替换的字符,replaceString 要替换的字符,num 替换次数 string.reverse(arg) ...
分类:
其他好文 时间:
2020-07-14 16:49:19
阅读次数:
60
https://www.luogu.com.cn/problem/P2089 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n, cnt=0, ans[60000][10];//最多情况是3^10= 59049,所以开这么大二维数组,用 ...
分类:
其他好文 时间:
2020-07-14 15:05:48
阅读次数:
388
题目链接:https://codeforces.com/contest/1380/problem/C 题意 给 $n$ 个数分组,要求每组的最小值乘以该组数的个数不小于 $x$ 。 题解 从大到小依次分即可。 代码 #include <bits/stdc++.h> using ll = long l ...
分类:
其他好文 时间:
2020-07-14 00:45:36
阅读次数:
83
#include<bits/stdc++.h> using namespace std; int a[105]= {0}; int b[105]; int pd(int q,int l) { int i; for(i=0; i<l; i++) { if(b[i]==q) { return 0; } ...
分类:
其他好文 时间:
2020-07-13 23:05:26
阅读次数:
107
reverse() std:: void reverse(s.begin(), s.end());上面是原地反转的方法,如果需要反转到别的 string 里面,一样简单: s1.assign(s.rbegin(), s.rend());效率也相当理想。 ...
分类:
其他好文 时间:
2020-07-13 21:50:27
阅读次数:
57
Cover the Tree 就当作是一个结论吧…当要用链覆盖所有的边时,对叶子节点根据dfs序排序后,根据$(i,i+s/2)$的配对规则进行配对即可,如果有奇数个叶子节点,则将其与根节点相连。 // Created by CAD on 2020/7/13. #include <bits/stdc ...
分类:
其他好文 时间:
2020-07-13 21:24:10
阅读次数:
94
Reverse Bits Reverse bits of a given 32 bits unsigned integer. Example 1: Input: 00000010100101000001111010011100 Output: 0011100101111000001010010100 ...
分类:
其他好文 时间:
2020-07-13 11:35:53
阅读次数:
58