随笔分类 - 解题报告
-
AcWing每日一题--蛇形矩阵
摘要:https://www.acwing.com/problem/content/758/ 模拟题 1 #include<iostream> 2 using namespace std; 3 const int N=110; 4 int a[N][N]; 5 int u[]={-1,0,1,0}; 6 阅读全文
-
AcWing每日一题--数字三角形
摘要:https://www.acwing.com/problem/content/900/ 典型的DP问题,状态表示f[i][j] 集合:所有从顶部走到当前位置的路径上的数字和的集合 属性:最大值 状态计算:f [ i ] [ j ]= max ( f[i-1][j-1] , f[i-1][j] )+a 阅读全文
-
AcWing每日一题--货仓选址
摘要:题目:https://www.acwing.com/problem/content/106/ 贪心,将商店从0~n-1编号 如果n是奇数,将货仓放在第n/2个商店上就可以了 如果n是偶数,将货仓放在n/2-1和n/2商店之间就可以了 1 #include<iostream> 2 #include<c 阅读全文
-
leetcoede 8 字符串转换整数
摘要:1 class At{ 2 string state="start"; 3 unordered_map<string,vector<string>>table={ 4 {"start",{"start","signed","in_number","end"}}, 5 {"in_number",{"e 阅读全文
-
AcWing 最短哈密顿路径(状态压缩dp)
摘要:1 /* 2 哪些点走过了,和现在位于那个点上,是建立状态转移的关键 3 */ 4 #include<iostream> 5 #include<climits> 6 #include<string> 7 #include<cstring> 8 using namespace std; 9 const 阅读全文
-
P2921 在农场万圣节(非递归的类似于记忆化搜索的巧妙方法||记忆化搜索||tarjan)
摘要:1、 //秉持着必然进入一个环的思想 #include<bits/stdc++.h> using namespace std; const int N=100009; int color[N];//记录此节点的颜色(也就是是哪个节点发出的路径经过了这个节点) int circle[N];//记录环大 阅读全文
-
P1064 金明的预算方案(01背包||有依赖的背包)
摘要:直接01背包硬刚,虽然容易理解,但是完全不适合附件多的情况 1 /* 2 1、只选主件 3 2、选主件和附件1 4 3、选主件和附件2 5 4、选主件和附件1.2 6 */ 7 #include <iostream> 8 #include<string> 9 #include<cstdio> 10 阅读全文
-
滑动窗口问题
摘要:https://www.nowcoder.com/practice/dcc301bc11a7420b88afdbd272299809?tpId=90&tqId=30813&tPage=2&rp=2&ru=/ta/2018test&qru=/ta/2018test/question-ranking 1 阅读全文
-
P3368树状数组2(树状数组//改段求点)
摘要:1 /* 2 段改求点 3 用树状数组维护差分数组 4 因为a[i]=d[1]...d[i] 5 所以用差分数组的化就很好进行查询操作 6 至于区间修改,因为[x,y]区间内加上k的操作对差分数组造成的改变只有d[x]和d[y+1] 7 直接用树状数组的基本操作给加上就好了 8 */ 9 #incl 阅读全文
-
P3373 树状数组1(树状数组//改点求段)
摘要:改点求段 1 #include<iostream> 2 using namespace std; 3 const int N=5e5+100; 4 int n,m; 5 int a[N]; 6 int c[N]; 7 int lowbit(int x) 8 { 9 return x&(-x); 10 阅读全文
-
P1197 星球大战(并查集+链式向前星)
摘要:1 #include<iostream> 2 using namespace std; 3 const int N=4e5+100; 4 struct edge 5 { 6 int from; 7 int to; 8 int nex; 9 }; 10 edge a[N]; 11 int head[N 阅读全文
-
P2024 食物链(种类并查集||带权并查集)
摘要:先写所谓的种类并查集。 就是开3*n的空间,前n为A,后边依次是B,C 食物链为A->B->C->A 对于每句话都是先判断是否合法,然后在改并查集就好了 1 #include<iostream> 2 #include<fstream> 3 using namespace std; 4 const i 阅读全文
-
P1111 修复公路(kruscal+并查集)
摘要:1 #include<iostream> 2 #include<cstring> 3 #include<climits> 4 #include<algorithm> 5 using namespace std; 6 struct edge 7 { 8 int x,y,t; 9 }a[100009]; 阅读全文
-
P1387 最大正方形+P1736 创意吃鱼法(矩形上的dp+预处理)
摘要:最大正方形 1 //找出一个01矩阵中最大的全为一的正方形,并输出边长 2 #include <iostream> 3 #include<cstdio> 4 #include<cstdlib> 5 #include<cmath> 6 #include<cstring> 7 #include<algo 阅读全文
-
P2330 繁忙的城市(krusal最小生成树)
摘要:直接干 1 #include<iostream> 2 #include<algorithm> 3 #include<climits> 4 using namespace std; 5 struct edge 6 { 7 int from,to,weight; 8 }a[100010];//存边 9 阅读全文
-
P1546 最短网络(kruscal+并查集)
摘要:从邻接矩阵中提取出边,然后跑一边kruscal 1 #include<iostream> 2 #include<algorithm> 3 using namespace std; 4 struct node 5 { 6 int x,y,w; 7 }; 8 int cnt=0;//记录边数 9 nod 阅读全文
-
P1290 欧几里得的游戏(博弈论)
摘要:博弈论是真的难!? 给你两个数,每次只能从大的那个减去小的数的正整数倍,先得到零的人获胜 分析一下,(假设为x,y,且x>y),x=ky+z,若k>=2,那么我(是不是就可以为所欲为了)想一下减完或者,留一个给对手减是不是都行,然后我再往后分析下,我不就必胜了么? 所以遇到了这种情况或者我可以直接赢 阅读全文
-
P1288 取数游戏(博弈论)
摘要:转载自https://blog.csdn.net/Brian_Pan_/article/details/103860752 可以把环想象成两条路,如果没有天生的0,那两条路就是一样的(如果有的话,就两个方向跑一遍,奇数个非零alice必胜) 如果是偶数个的话,就没有必胜的策略了,只能根据bob所走的 阅读全文
-
P1341 无序字母对(欧拉回路+并查集)
摘要:1 //并查集判联通,dfs求解欧拉回路 2 #include<iostream> 3 using namespace std; 4 const int N=150; 5 int mp[N][N];//邻接矩阵存图 6 int d[N];//点的度数 7 char res[N*N];//大于C(52 阅读全文
-
P1330 封锁阳光大学(搜索+图的链式向前星存储)
摘要:给你一幅图,问你最少占领几个点,能够封锁阳光大学,但是不能占领一条边的两个点 就是每条边有且只有一个点能被占领,这么一来,每个连通分量只可能有两个方案(占领变不占领),所以直接搜,加上少的就好了 1 #include<iostream> 2 using namespace std; 3 const 阅读全文