- 博客(13)
- 收藏
- 关注
原创 算法之生成全排列
#include <iostream>#include <string>#include <vector>#include <climits>#include <algorithm>vector<vector<int>> res;vector<int> p;void generatePermutation(const vector<int>& array, int index
2021-02-09 16:06:01 78
原创 区间动态规划 LeetCode 1000 Minimum Cost to Merge Stones
区间动态规划 LeetCode 1000 Minimum Cost to Merge Stones
2021-02-03 15:51:28 109
原创 区间动态规划 石子合并
#include <iostream>#include <string>#include <vector>#include <climits>using namespace std;int mergeStones(const vector<int>& stones){ int n = stones.size(); if ( n ==0 ) return 0; vector<vec...
2021-02-03 15:42:51 162 1
原创 动态规划 LeetCode 10 Regular Expression Matching
动态规划 LeetCode 10 Regular Expression Matching
2021-01-27 10:03:14 109
原创 Minimum Edit Distance
#include <iostream>#include <vector>#include <string>using namespace std;int minimumEditDistance(string s1, string s2){ int m = s1.length(); int n = s2.length(); vector<vector<int>> dp(m + 1, vector<int&g...
2021-01-15 01:23:33 88
原创 Longest Common Subsequence
#include <iostream>#include <vector>#include <string>using namespace std;//int dp[1000][1000];int LCS(string s1, string s2){ int m = s1.length(); int n = s2.length(); vector<vector<int>> dp(m+1, vector<i...
2021-01-14 21:21:01 113
原创 判断一个字符串是不是另一个字符串的子字符串
#include <iostream>#include <string>using namespace std;bool isSubString(string s, string t){ if ( t.length() < s.length() ) return false; for (int i = 0; i <= t.length() - s.length(); i++) { int j; ...
2021-01-12 22:30:29 623
原创 判断一个序列是不是另一个序列的子序列
bool isSubSequence(string s, string t){ int j = 0; for (int i = 0; i < t.length() && j < s.length() ; i++) { if (s[j] == t[i]) j++; } if (j == s.length() ) return true; else ...
2021-01-12 21:28:24 523
原创 TCO 2014 Finals FrozenStandings 分析与题解
TCO 2014决赛题。题目大意: 给定一个数组X[i],比如{1, 0, 1, 1, 1, 0, 1, 1}.,表示选手当前做出的题。现在每位选手将再作一道题,即每位选手最后做出的题为X[i]或X[i] + 1,做出较多题的选手排在前面,如果两个选手做出相同数量的题,编号较小的选手排在前面。问最后有多少种选手?
2017-01-30 20:02:49 547
原创 topcoder SRM 517 div1 AdjacentSwaps 分析与题解
题目大意:给定一个N个数的排列,要将其经过N-1次的交换(只能是相邻位置数的交换),变成0到N-1的排列,问有多少种交换的排列方式。rng_58的题,费脑筋。这个一个关于排列的inversion的题。排列的inversion代表排列的有序程度。排列的inversion的数量从0到n*(n-1)/2。由此得出结论,要将一个排列经过N-1次的交换,变成0到N-1的排列,其inversi
2017-01-29 00:10:25 338
原创 topcoder srm 696 div2 Clicountingd2分析
topcoder srm 696 div2 Clicountingd2分析 图的clique是图的完全子图(即子图的任意两个顶点之间都有边连接),clique的大小是clique中顶点的数量。给定一个图,其中有些顶点之间的边是未知的,以'?'表示。假如有k条边是未知的,那么总共会有2^k个不同的图,求这2^k个图的最大clique的大小的和。
2016-08-29 01:36:00 531
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人