上一页 1 ··· 7 8 9 10 11 12 13 14 下一页
摘要: 贪心策略: 要么让最快的人依次把最慢的两个人渡过河再回来。要么让最快的两个人先过河,最快的人回来,然后最慢的两个过河,第二快的回来。直到剩余人数少于4人为止; 1700 Accepted 320K 16MS G++ 668B #include "cstdio" #include "algorithm 阅读全文
posted @ 2019-01-31 12:18 Jathon-cnblogs 阅读(99) 评论(0) 推荐(0) 编辑
摘要: dp[i][j]表示i个砖头构成的最高台阶不高于j的楼梯数目 Accepted 1163 C++11 0 2280 #include "bits/stdc++.h" using namespace std; typedef long long LL; const int MAXN = 500 + 5 阅读全文
posted @ 2019-01-31 11:34 Jathon-cnblogs 阅读(301) 评论(0) 推荐(0) 编辑
摘要: 就是分别以1到9作为开头构造结果,取最小答案。看了参考书之后才做出来,对参考书上的代码进行了一些改进 Accepted 1177 C++11 0 408 #include "bits/stdc++.h" using namespace std; // 参考书上说经在线测试ans的位数最高在15000 阅读全文
posted @ 2019-01-30 20:58 Jathon-cnblogs 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 设 ans 为满足前 n - 1个同余方程的解,lcm是前n - 1个同余方程模的最小公倍数,求前n个同余方程组的解的过程如下: ①设lcm * x + ans为前n个同余方程组的解,lcm * x + ans一定能满足前n - 1个同余方程; ②第 n 个同余方程可以转化为a[n] * y + b 阅读全文
posted @ 2019-01-29 12:46 Jathon-cnblogs 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 这题要求两个串中的最长相同子串的长度。高度数组可以求一个串中的最长相同子串的长度。所以想到把两个串连起来,但是这样又会产生一些新的串(第一个串的结尾和第二个串的开头组成的)于是在两个串中间放一个'\0'分隔,正好'\0'是字符里最小的,不会对第一个串的排序产生影响。 Accepted 1403 62 阅读全文
posted @ 2019-01-27 13:35 Jathon-cnblogs 阅读(210) 评论(0) 推荐(0) 编辑
摘要: 看了求后缀数组的倍增法之后很快就理解了,但是自己写的倍增法用map排序还是超时了。然后看了两天别人写的模板,题目是通过了,但感觉代码还是半懂半背的。以后多熟悉熟悉吧; 后缀数组 #include "bits/stdc++.h" using namespace std; const int MAXN 阅读全文
posted @ 2019-01-25 21:47 Jathon-cnblogs 阅读(198) 评论(0) 推荐(0) 编辑
摘要: Rabin-Karp Accepted 1711 904MS 5272K 1310 B G++ #include "bits/stdc++.h" using namespace std; typedef long long LL; const int MAXN = 1e6 + 5; const in 阅读全文
posted @ 2019-01-23 15:58 Jathon-cnblogs 阅读(234) 评论(0) 推荐(0) 编辑
摘要: 上来先一顿暴力,结果70分就超时了。 然后意识到稀疏矩阵,有很多0,如果c[i][j] != 0,那么一定存在至少一个k满足a[i][k] != 0 && b[k][j] != 0; 然后就一发水A啦 1675 稀疏矩阵乘积 AC G++ 35ms 15MB #include "bits/stdc+ 阅读全文
posted @ 2019-01-22 14:37 Jathon-cnblogs 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 时间限制:5000ms 单点时限:1000ms 内存限制:256MB 描述 给定一个字符串类型的数组strs,请找到一种拼接顺序,使得将所有的字符串拼接起来组成的大字符串是所有可能性中字典顺序最大的,并输出这个大字符串。 输入 第一行:N(1<N<=100),代表数组的长度第二行:N个字符串,作为数 阅读全文
posted @ 2019-01-21 18:33 Jathon-cnblogs 阅读(249) 评论(0) 推荐(0) 编辑
摘要: 计数排序 Accepted 1425 483MS 5276K 997 B G++ #include "bits/stdc++.h" using namespace std; typedef long long LL; typedef pair<int, int> PII; const int INF 阅读全文
posted @ 2019-01-21 11:08 Jathon-cnblogs 阅读(474) 评论(0) 推荐(1) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 14 下一页