02 2020 档案
-
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 阅读全文
-
树状数组
摘要:开局一张图,剩下全靠编。 对于树状数组,我的理解是有技巧的应用前缀和+神仙一般的二进制规律 1、改点求段 改点从下往上,将全部包括了这个点的c全部更改 1 int lowbit(int x) 2 { 3 return x&(-x); 4 } 1 void add(int x,int y)//将第x个 阅读全文
-
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]; 阅读全文