1741: [Usaco2005 nov]Asteroids 穿越小行星群 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 231 Solved: 166[Submit][Status][Discuss] Description Bessie wants to navigate her spaceship through a dangerous asteroid field in the shape of an N x N grid (1 <= N…
Description Bessie wants to navigate her spaceship through a dangerous asteroid field in the shape of an N x N grid (1 <= N <= 500). The grid contains K asteroids (1 <= K <= 10,000), which are conveniently located at the lattice points of the…
网络流,对于每一个行星,将行星所在行到行星连一条流量为1的边,将行星到其所在列连一条流量为1的边,从源点到所有行连一条流量为1的边,将所有列到汇点都连一条流量为1的边,最大流即为答案. 代码 #include<cstdio> #include<algorithm> #define N 1000050 #define M 1000050 const int inf =0x37373737; using namespace std; int n,m,i,a,b; struct Dini…
二分图最大点覆盖模型,因为对于一个点(x,y)显然只要选x或者y就好了,于是连边,跑最大匹配=最大点覆盖(不会证) #include<iostream> #include<cstdio> using namespace std; const int N=10005,inf=1e9; int n,m,h[N],cnt,con,lk[N],v[N],ti; struct qwe { int ne,to; }e[100005]; int read() { int r=0,f=1; cha…
dp... dp( l , r , k ) , 表示 吃了[ l , r ] 的草 , k = 1 表示最后在 r 处 , k = 0 表示最后在 l 处 . -------------------------------------------------------------- #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #define rep…