信息学奥赛提高篇
文章平均质量分 59
太阳湖散步
这个作者很懒,什么都没留下…
展开
-
Part2.2字符串算法-KMP 算法
A 剪花布条KMP模板#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;const int N = 10010;int n, m;char s[N], p[N];int ne[N];void work(){ for (int i = 2, j = 0; i <= m; i ++ )原创 2021-06-16 12:38:48 · 56 阅读 · 0 评论 -
Part2.3字符串算法-Trie 字典树
A Phone List#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;const int N = 100010;int n;char s[N];int tr[N][10], cnt[N], idx;void insert(char s[]){ int p = 0; for (int原创 2021-05-20 22:24:10 · 87 阅读 · 0 评论 -
Part1.3 基础算法-深搜的剪枝技巧
Part1.3 基础算法-深搜的剪枝技巧A数的划分A数的划分dfs搜索,我的弱项#include <bits/stdc++.h>using namespace std;const int N = 1010;int n, k;int a[N];int ans;void dfs(int u, int left){ if (left <= 0) return; if (u >= k) { ans ++; r原创 2021-04-13 11:07:05 · 117 阅读 · 0 评论 -
Part5.1 动态规划-区间类动态规划
Part5.1 动态规划-区间类动态规划石子合并石子合并石子合并,区间DP将环扩为2*n/* *@author SunLakeWalk */#include <iostream>#include <cstring>#include <cstdio>#include <algorithm>#include <cmath>#include <iomanip>#include <limits.h>#in原创 2021-04-03 21:10:48 · 71 阅读 · 0 评论 -
Part6.1 数学基础-快速幂
Part6.1 数学基础-快速幂快速幂模板[A序列的第 k 个数](https://ac.nowcoder.com/acm/contest/977/A)快速幂模板LL qmi(int a, int b){ LL ans = 1; while (b) { if (b & 1) ans = ans * a % mod; a = a * a % mod; b >>= 1; } return ans;}A序列的第 k 个数快速幂模板题#include <原创 2021-03-30 16:29:23 · 149 阅读 · 0 评论 -
Par4.1 数据结构-树状数组
Par4.1 数据结构-树状数组A序列操作[数星星 Stars](https://ac.nowcoder.com/acm/contest/965/B)A序列操作单点修改,区间查询,模板题#include <bits/stdc++.h>using namespace std;typedef long long ll;const int N = 1000010;int n, q;ll tr[N], a[N];int lowbit(int x){ return x &a原创 2021-03-30 16:24:54 · 58 阅读 · 0 评论 -
Part1.2 基础算法-二分与三分
Part1.2 基础算法-二分与三分A愤怒的牛A愤怒的牛二分答案#include <bits/stdc++.h>using namespace std;const int N = 100010;int n, m;int a[N];inline bool check(int mid){ int cnt = 1; int t = a[0] + mid; for (int i = 1; i < n; i ++ ) { if原创 2021-03-23 21:29:30 · 214 阅读 · 0 评论 -
Part1.1 基础算法-贪心算法
Part1.1 基础算法-贪心算法A活动安排法一:我们按照左端点来进行排序法二:我们按照区间右端点进行排序 (比法一更好)A活动安排法一:我们按照左端点来进行排序将区间按照区间左端点进行从小到达排序,然后,我们来进行分析我们贪心的来考虑,ans(答案)、ed(前一个区间的右区间)我们用最贪心的角度来考虑,为了让1到n容纳更多的区间,我们找到两种也只有这两种可以让结果更有的方法1.如果当前区间的右端点小于ed,那么,ed=右端点2.如果当前区间的左端点大于ed,那么,ed=左端点,ans++;原创 2021-03-17 21:57:45 · 266 阅读 · 0 评论