随笔 - 531
文章 - 0
评论 - 3
阅读 -
10215
随笔分类 - 图论
最小费用最大流( spfa )
摘要:const int N =5005, M=1e5+100; #define inf 1e9 int all=1,hd[N],go[M],w[M],nxt[M],cost[M]; int S,T,n,m; int pre[N],mn[N],dis[N],vis[N],ans=0; void add_(
阅读全文
P2764 最小路径覆盖问题
摘要:求最少的路径数目覆盖DAG每个点(无点交集 #include<iostream> #include<algorithm> #include <queue> using namespace std ; const int N=500,M=5e5+5; const int inf =1e9+7; int
阅读全文
P2825 [HEOI2016/TJOI2016]游戏
摘要:给定一张 n×m 的网格地图:其中 * 代表空地,炸弹的威力可以穿透,可以在空地上放置一枚炸弹。 x 代表软石头,炸弹的威力可以穿透,不能在此放置炸弹。# 代表硬石头,炸弹的威力是不能穿透的,不能在此放置炸弹。 例如:给出 1×41×4 的网格地图 *xx*,这个地图上最多只能放置一个炸弹。给出另一
阅读全文
P1129 [ZJOI2007] 矩阵游戏
摘要:#include<iostream> #include<algorithm> #include <queue> using namespace std ; const int N=6e4,M=1e5+10; const int inf =1e9+7; int all=1,hd[N],go[M],w[
阅读全文
P3254 圆桌问题
摘要:关于网络流解决二分图问题,输出具体方案,看一下残量图的边==0 ?就好 #include <iostream> #include<cmath> #include <queue> #include <cstring> using namespace std; const int N =1e4,M=5e
阅读全文
P2766 最长不下降子序列问题
摘要:给定正整数序列 x1…,xn 1.计算其最长不下降子序列的长度 ss。 2.如果每个元素只允许使用一次,计算从给定的序列中最多可取出多少个长度为 ss 的不下降子序列。 3.如果允许在取出的序列中多次使用 x1 xn(其他元素仍然只允许使用一次), 则从给定序列中最多可取出多少个不同的长度为 ss
阅读全文
P2472 [SCOI2007] 蜥蜴
摘要:在一个 R 行 C列的网格地图中有一些高度不同的石柱,第 ii 行 jj 列的石柱高度为 a[i][j] 一些石柱上站着一些蜥蜴,你的任务是让尽量多的蜥蜴逃到边界外。 每行每列中相邻石柱的距离为 1,蜥蜴的跳跃距离是 D,即蜥蜴可以跳到平面距离不超过 D 的任何一个石柱上。 石柱都不稳定,每次当蜥蜴
阅读全文
P2763 试题库问题
摘要:假设一个试题库中有 n道试题。每道试题都标明了所属类别。 同一道题可能有多个类别属性。现要从题库中抽取 m道题组成试卷。并要求试卷包含指定类型的试题mi 道 任务: 求满足要求的组卷方案。 试卷和类别连线(z=1) ,S和题目连线(z=1) 类别和T连线( z=m[i] ) #include <io
阅读全文
P2515 [HAOI2010]软件安装
摘要:题目就是树上背包,但要先缩点为DAG #include <iostream> #include <cstring> #include <vector> #include <stack> using namespace std ; const int N=503,M=1003; //#define i
阅读全文
P2746 [USACO5.3]校园网Network of Schools
摘要:https://www.luogu.com.cn/problem/P2746 第二问, 就是在 入度为0(或者出度为0)那排的点之间加边 #include <bits/stdc++.h> using namespace std ; const int N=1e4+2; vector<int> g[N
阅读全文
P1462 通往奥格瑞玛的道路
摘要:城市之间有 mm 条双向的公路,连接着两个城市,从某个城市到另一个城市,会遭到联盟的攻击,进而损失一定的血量。 每次经过一个城市,都会被收取一定的过路费(包括起点和终点)。路上并没有收费站。 假设 1 为暴风城,n为奥格瑞玛,而他的血量最多为 b,出发时他的血量是满的。如果他的血量降低至负数,则他就
阅读全文
P2065 [TJOI2011] 卡片
摘要:桌子上有 mm 张蓝色卡片与 nn 张红色卡片,每张卡片上有一个大于 1 的整数。 现在你要从桌子上拿走一些卡片,分若干次拿。每次只能拿走一组卡片:这组卡片颜色不同,并且两张卡片上面的数字的最大公约数大于 1。 问:最多可以从桌上拿走多少组卡片。 #include <iostream> #inclu
阅读全文
最小生成树板子
摘要:#include <bits/stdc++.h> using namespace std ; const int N=5003,M=2e5+2; int f[N],n,m; struct E{ int x,y,z; }e[M]; int find(int x){ return x==f[x]?x:f
阅读全文
P1038 [NOIP2003 提高组] 神经网络
摘要:https://www.luogu.com.cn/problem/P1038 #include <iostream> #include<queue> #include <vector> #include <cstring> using namespace std; const int N=104,
阅读全文
POJ 1149 PIGS
摘要:https://vjudge.net/problem/POJ-1149 #include <iostream> #include<queue> #include <cstring> #define IOS std::ios::sync_with_stdio(0) using namespace st
阅读全文
AcWing 372. 棋盘覆盖
摘要:给n*n的方格图铺满1*2 的长条,且某些位置不能铺,问最多能放多少个长条 #include <iostream> #include<queue> #include <vector> #include <cstring> using namespace std; const int N =110 ,
阅读全文
二分图 笔记
摘要:二分图最大匹配 1.匈牙利算法: 做法是 u 尽量 匹配 v , 如果v已有配对 y,就重新配对 y https://www.luogu.com.cn/record/128670058 2. 网络流解决 性质: 最大独立集= 点数-最大匹配 最小顶点集覆盖数= 最大匹配
阅读全文
#10108. 「一本通 3.7 练习 2」Ant Trip
摘要:无向图一笔画需要多少次(欧拉路径的条数) 答案:奇数点的个数 / 2 这题需要维护联通块,用并查集即可 #include <iostream> #include <algorithm> #include <cstring> #include <stack> using namespace std ;
阅读全文
#10105. 「一本通 3.7 例 1」欧拉回路
摘要:求欧拉回路( dfs ) #include <bits/stdc++.h> using namespace std ; const int N=1e6+3,M=2e6+3; inline int read(){ int res = 0, flag = 1; char ch = getchar();
阅读全文
1515:网络协议
摘要:板子题 缩点找出入度为0的点 即可 第二问 max(p,q) #include <bits/stdc++.h> using namespace std ; const int N=103; vector<int> g[N],graph[N]; int n,pool,dfn[N],low[N],in[
阅读全文