随笔分类 -  ACM

摘要:https://ac.nowcoder.com/acm/problem/21302 直接考虑了01背包,目前还不懂为什么会是-1 1 #include <bits/stdc++.h> 2 using namespace std; 3 #define int long long 4 const int 阅读全文
posted @ 2020-07-18 21:33 Hazelxcf 阅读(127) 评论(0) 推荐(0)
摘要:二进制拆分法 阅读全文
posted @ 2020-07-18 20:11 Hazelxcf 阅读(45) 评论(0) 推荐(0)
摘要:给定两个长度分别为N和M的字符串A和B,求既是A的子序列又是B的子序列的字符串长度最长是多少。 输入格式 第一行包含两个整数N和M。 第二行包含一个长度为N的字符串,表示字符串A。 第三行包含一个长度为M的字符串,表示字符串B。 字符串均由小写字母构成。 输出格式 输出一个整数,表示最大长度。 数据 阅读全文
posted @ 2020-05-15 10:35 Hazelxcf 阅读(115) 评论(0) 推荐(0)
摘要:给定一个浮点数n,求它的三次方根。 输入格式 共一行,包含一个浮点数n。 输出格式 共一行,包含一个浮点数,表示问题的解。 注意,结果保留6位小数。 数据范围 −10000≤n≤10000 输入样例: 1000.00 输出样例: 10.000000 #include <bits/stdc++.h> 阅读全文
posted @ 2020-05-11 11:47 Hazelxcf 阅读(369) 评论(0) 推荐(0)
摘要:注意:题目说了,所有道路单行 所以了两次迪杰斯特拉 #include <bits/stdc++.h> using namespace std; const int nn = 1e3 + 5; const int mm = 1e5 + 5; int d[nn],head[nn],ver[mm],edg 阅读全文
posted @ 2020-05-02 12:14 Hazelxcf 阅读(155) 评论(0) 推荐(0)
摘要:1 #include <bits/stdc++.h> 2 using namespace std; 3 #define int long long 4 const int maxn = 1e4 + 10; 5 int n,k,b[maxn],dp[maxn]; 6 struct node{ 7 in 阅读全文
posted @ 2020-04-30 10:18 Hazelxcf 阅读(98) 评论(0) 推荐(0)
摘要:和LIS反着 本题直接做就行, 注意计算方案数,不是说找到最大的方案,然后再找比他小的就可以了,还要注意去重,所以再建立一个数组c;记录方案数目 1 #include <bits/stdc++.h> 2 using namespace std; 3 #define int long long 4 c 阅读全文
posted @ 2020-04-30 09:25 Hazelxcf 阅读(147) 评论(0) 推荐(0)
摘要:参考的大佬的博客 求什么设什么,dp[l][r]为l到r堆范围的石子数量的最值 相邻合并为一堆,所以枚举最小值是2 这两堆又是由另外的两堆石子合并,可认为是由dp[l][k]和dp[k + 1][r] 根据k的值将对应范围分为了两部分,然后根据公式会分为更多部分 #include <bits/std 阅读全文
posted @ 2020-04-28 21:19 Hazelxcf 阅读(117) 评论(0) 推荐(0)
摘要:链接 最少的反转次数使的点数只差最小 注意绝对值 dp[i][j]表示前i个物品达到j,可以反转,也可以不转 int g = a[i] - b[i]; 状态转移方程 dp[i][j] = min(dp[i - 1],[j - g + 5000],dp[j + g + 5000]+ 1); 为什么要加 阅读全文
posted @ 2020-04-26 16:38 Hazelxcf 阅读(173) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2020-04-26 07:50 Hazelxcf 阅读(0) 评论(0) 推荐(0)
摘要:链接 刚开始想的是两次01背包,把第一次走过的给记录下来。好像不太好记录, 参考了大佬的博客,数据范围不是很大,四维数组就可以了, a,b第一个人走的,c,d代表第二个人 dp[a][b][c][d] = max{dp[a][b -1][c][d -1] , dp[a - 1][b][c -1][d 阅读全文
posted @ 2020-04-25 17:41 Hazelxcf 阅读(140) 评论(0) 推荐(0)
摘要:难点:字符串处理 #include <iostream> #include <cstring> #include <cstdio> #include <map> using namespace std; char ss[100],s1[50],s2[50]; string s3; map<strin 阅读全文
posted @ 2020-04-22 20:38 Hazelxcf 阅读(107) 评论(0) 推荐(0)
摘要:KMP next数组:next[i]表示以i为终点的前缀的最长相同前后缀长度 拓展KMP extend数组: extend[i]表示文本串T中以i为起点的后缀与模式串S的最大相同前缀的长度 next数组:next[i]表示S以i为终点的最大相同前后缀长度 阅读全文
posted @ 2020-04-21 08:34 Hazelxcf 阅读(66) 评论(0) 推荐(0)
摘要:题意:给你n个由小写字母组成的字符串S,求出能找到k个S的新字符串,并且尽量短 考察nxt数组的含义 #include <iostream> #include <cstring> #include <cstdio> #include <algorithm> using namespace std; 阅读全文
posted @ 2020-04-21 08:23 Hazelxcf 阅读(126) 评论(0) 推荐(0)
摘要:题意:给出一个字符串,问字符串中存在多少子串,使得这些子串既是字符串的前缀,又是字符串的后缀,要求从小到大依次输出这些子串的长度。 思路:根据 next 数组的定义,可以得到前缀 next[len] 长度的子串与后缀 next[len] 长度的子串相同,因此求出 len 处的 next 值,然后向下 阅读全文
posted @ 2020-04-21 08:00 Hazelxcf 阅读(143) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2020-04-19 08:36 Hazelxcf 阅读(0) 评论(0) 推荐(0)
摘要:小H在一个划分成了n*m个方格的长方形封锁线上。 每次他能向上下左右四个方向移动一格(当然小H不可以静止不动), 但不能离开封锁线,否则就被打死了。 刚开始时他有满血6点,每移动一格他要消耗1点血量。一旦小H的 血量降到 0, 他将死去。 他可以沿路通过拾取鼠标(什么鬼。。。)来补满血量。只要他走到 阅读全文
posted @ 2020-04-18 17:27 Hazelxcf 阅读(239) 评论(0) 推荐(0)
摘要:样例输 3 ba a aba 样例输出复制 2 3 1 #include <iostream> #include <cstring> #include <algorithm> #include <cmath> #include <cstdio> #include <map> using namesp 阅读全文
posted @ 2020-04-16 21:34 Hazelxcf 阅读(160) 评论(0) 推荐(0)
摘要:It's easy to tell if two words are identical - just check the letters. But how do you tell if two words are almost identical? And how close is "almost 阅读全文
posted @ 2020-04-16 21:20 Hazelxcf 阅读(178) 评论(0) 推荐(0)
摘要:我写的,第二个样例不对,感觉按照题目说的写出来 #include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int t,n,m,k,a[maxn],b[maxn]; int c; int main() { //fr 阅读全文
posted @ 2020-04-14 11:24 Hazelxcf 阅读(193) 评论(0) 推荐(0)