自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(11)
  • 收藏
  • 关注

原创 并查集专题

一.P1511 - [蓝桥杯2020初赛] 七段码 - New Online Judge (ecustacm.cn) #include <iostream> #include <cstring> #include <algorithm> using namespace std; const int N = 10; int e[N][N]; bool st[N]; int p[N]; int find(int x) { if(p[x] != x) p[x] =

2022-04-04 15:14:45 214

原创 简单打印矩阵

一.P1510 - [蓝桥杯2020初赛] 蛇形填数 - New Online Judge (ecustacm.cn) #include<iostream> using namespace std; int a[40][40]; int main() { int ans=1; for(int i=1;i<=40;i++){ if(i%2==1){ for(int x=i,y=1;x>=1&&y<=i;x--,y++) a[x][y]=an

2022-04-04 14:04:36 263

原创 动态规划算法

一.最大正方形(ZUEBOJ (icode8.cn)) 用 dp(i, j) 表示以(i,j) 为右下角,且只包含 1 的正方形的边长最大值。如果我们能计算出所有dp(i,j) 的值,那么其中的最大值即为矩阵中只包含 1 的正方形的边长最大值。 如果该位置的值是 1,则dp(i,j) 的值由其上方、左方和左上方的三个相邻位置的dp 值决定。具体而言,当前位置的元素值等于三个相邻位置的元素中的最小值加 1,状态转移方程如下: dp(i,j)=min(dp(i−1,j),dp(i−1,j−1),dp..

2022-04-04 14:02:18 1261

原创 暴力算法简化

一.[蓝桥杯2021初赛] 货物摆放(P1552 - [蓝桥杯2021初赛] 货物摆放 - New Online Judge (ecustacm.cn) #include<iostream> #include<cmath> using namespace std; long long n=2021041820210418,n1,a,b,c,ans; int main(){ //n=n1*a,n1=b*c; for(a=1;a<=sqrt(n);a++){//利用sqrt

2022-03-22 23:02:45 81

原创 模拟算法专题

1.外卖店优先级(New Online Judge) #include<bits/stdc++.h> using namespace std; const int N=100010; int order[N]; //order[id] 第id号店上一次的订单 int prior[N]; //prior[id] 第id号店的优先级 int flag[N]; //flag[id] 第id号店在不在优先缓存中 struct node { int time,id; } a[N]; bool cmp

2021-11-30 23:13:42 391

原创 DP背包问题

一.糖果(New Online Judge) #include<bits/stdc++.h> using namespace std; int dp[1<<20]; //dp[v]:得到口味为v时需要的最少糖果包数量 int ST[100]; //ST[i]:第i包糖果的口味 int main() { int n,m,k; cin>>n>>m>>k; int tot=(1<<m)-1; //tot:二进制是m个1,表示所有m种

2021-11-26 13:10:48 502

原创 深度搜索(DFS)

一.方格分割(New Online Judge); #include<bits/stdc++.h> using namespace std; int X[] = {0, -1, 1, 0, 0}; int Y[] = {0, 0, 0, -1, 1}; bool vis[10][10]; int res = 0; void dfs(int x, int y){ if(x == 0 || y == 0 || x == 6 || y == 6){ res++; return ; } for(in

2021-11-22 23:15:07 555

原创 广度搜索(BFS)

一.跳蚂蚱(New Online Judge) #include<bits/stdc++.h> using namespace std; struct node { node() {} node(string ss, int tt) { s = ss, t = tt; } string s; int t; }; map<string, bool> mp; queue<node> q; void solve() { while(!q.empty()) {

2021-11-22 23:09:22 228

原创 算法的积累

一.求两个正整数的最大公约数 欧几里得算法:又称辗转相除法,是指用于计算两个非负整数a,b的最大公约数。 计算公式gcd(a,b) = gcd(b,a mod b)。

2021-11-02 21:02:52 120

原创 贪心知识点总结

1.计算最大的正方形块。area[i][j]:表示以i,j为左上角的正方形的宽度。则 area[i][j] = min(area[i-1][j],area[i][j-1],area[i-1][j-1])+1.

2021-07-27 17:33:58 114

原创 KMP算法

一.复习并理解KMP算法中计算Next数组的代码: void getnext() { int i=0; int j=-1; next[0]=-1; while(i<len) { if(j==-1||s[i]==s[j]) { i++; j++; next[i]=j; } else j=next[j]; } } next[i](i从1开始算)代表着,除去第i个数,在一个字符串里面从第一个数到第(i-1)字符串

2021-06-30 16:16:18 177

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除