二分图最小不相交路径覆盖 #include<bits/stdc++.h> using namespace std; ; ; ; ], nxt[MAXM << ], f[MAXM << ], ed = , S, T; inline void addedge(int u, int v, int cap) { to[++ed] = v; nxt[ed] = Head[u]; Head[u] = ed; f[ed] = cap; to[++ed] = u; nxt[ed] =…
P2172 [国家集训队]部落战争 每个点仅走一次:最小路径覆盖 套路地拆点,具体看代码中的$draw()$ 流量每增加1,意味着一支军队可以多走一格,代价减少1 最后答案即为总点数$-dinic()$ #include<iostream> #include<cstdio> #include<cstring> #include<queue> using namespace std; int read(){ ,f=; ') f=f&&(c!='…
洛谷AC传送门! step1: 题目大意 有一张M x N的网格图,有一些点为“ * ”可以走,有一些点为“ x ”不能走,每走一步你都可以移动R * C 个格子(参考象棋中马的走法),且不能回头,已经走过的点不能再被走第二次. 每次,你可以从任意“ * ”能走的点出发,求至少要多少次才能走完所有的能走的点. step2: 题意翻译 ​ 那么题意便可以转化为: 一条路径可以看做从任意一个没有到达过的可通过的点出发到任意一个其他的可以通过却没有被到达过的点的一条路径, 要使每个点都被经过, 并且每…
题目链接:https://www.luogu.org/problemnew/show/P2172 分析: 不要被[国家集训队]的标签吓到,其实这题不是很难. 本题可以对比P4304 [TJOI2013]攻击装置:互不攻击的网络流问题来想. 这道题唯一添加的条件就是只能从上往下征战,于是我们就从8个方向缩减到了四个放向,哪四个呢? aa[1]=r;bb[1]=-c; aa[2]=r;bb[2]=c; aa[3]=c;bb[3]=-r; aa[4]=c;bb[4]=r; 变量名较丑 然后还是要循环每…
P4304 [TJOI2013]攻击装置 题目描述 给定一个01矩阵,其中你可以在0的位置放置攻击装置. 每一个攻击装置(x,y)都可以按照“日”字攻击其周围的8个位置(x-1,y-2),(x-2,y-1),(x+1,y-2),(x+2,y-1),(x-1,y+2),(x-2,y+1),(x+1,y+2),(x+2,y+1) 求在装置互不攻击的情况下,最多可以放置多少个装置. 输入输出格式 输入格式: 第一行一个整数N,表示矩阵大小为N*N. 接下来N行每一行一个长度N的01串,表示矩阵. 输出…
Consider a town where all the streets are one-way and each street leads from one intersection to another. It is also known that starting from an intersection and walking through town's streets you can never reach the same intersection i.e. the town's…
传送门 枚举球的个数 num 如果 i < j && (i + j) 是完全平方数,那么 i -> j' 连一条边 再加一个超级源点 s,s -> i 再加一个超级汇点 t,i' -> t 那么当前可以放的柱子的最小数量就是最小不相交路径数 如果当前的最小不相交路径数 > num,break 求最大流的时候别忘了记录方案 ——代码 #include <cmath> #include <queue> #include <cstdio…
传送门:http://poj.org/problem?id=1422 Air Raid Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9303   Accepted: 5570 Description Consider a town where all the streets are one-way and each street leads from one intersection to another. It is…
题目描述 lanzerb的部落在A国的上部,他们不满天寒地冻的环境,于是准备向A国的下部征战来获得更大的领土. A国是一个M*N的矩阵,其中某些地方是城镇,某些地方是高山深涧无人居住.lanzerb把自己的部落分成若干支军队,他们约定: 每支军队可以从任意一个城镇出发,并只能从上往向下征战,不能回头.途中只能经过城镇,不能经过高山深涧. 如果某个城镇被某支军队到过,则其他军队不能再去那个城镇了. 每支军队都可以在任意一个城镇停止征战. 所有军队都很奇怪,他们走的方法有点像国际象棋中的马.不过马每…
Air Raid Consider a town where all the streets are one-way and each street leads from one intersection to another. It is also known that starting from an intersection and walking through town's streets you can never reach the same intersection i.e. t…