# 【BZOJ 1711】[Usaco2007 Open] Dining吃饭

《网络流建模汇总》的例题

#include<bits/stdc++.h>
#define LL long long
using namespace std;

const int N = 400+9;
const int M = 1000000;
const int INF = 1000000000;

queue<int> que;

char c=getchar(); int ret=0,f=1;
while (c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();}
while (c<='9'&&c>='0') {ret=ret*10+c-'0';c=getchar();}
return ret*f;
}

inline void Add_Edge(int u, int v, int f) {
static int TT = 1;
to[++TT] = v; nxt[TT] = head[u]; head[u] = TT; flow[TT] = f;
to[++TT] = u; nxt[TT] = head[v]; head[v] = TT; flow[TT] = 0;
}

inline bool BFS(){
memset(dis,-1,sizeof(dis));
dis[S] = 0; que.push(S);
while (!que.empty()) {
int w = que.front(); que.pop();
for (int i=head[w];i;i=nxt[i]) if (flow[i] && !~dis[to[i]])
dis[to[i]] = dis[w] + 1, que.push(to[i]);
} return ~dis[T];
}

int DFS(int w, int f) {
if (w == T) return f;
else { int ret = 0;
for (int &i=cur[w];i;i=nxt[i]) if (flow[i] && dis[to[i]] == dis[w] + 1) {
int tmp = DFS(to[i], min(f, flow[i]));
ret += tmp; f -= tmp; flow[i] -= tmp; flow[i^1] += tmp;
if (!f) break;
} return ret;
}
}

inline int Dinic(){
int ret = 0; while (BFS()) {
ret += DFS(S,INF);
} return ret;
}

int main(){
for (int i=1,t1,t2;i<=n;i++) {
} printf("%d\n",Dinic());
return 0;
}


## 20 thoughts to “【BZOJ 1711】[Usaco2007 Open] Dining吃饭”

1. Hi there mates, good article and fastidious urging commented here, I am really enjoying by
these.

so I am going to inform her.

3. Hi colleagues, fastidious piece of writing and nice urging commented here, I am truly enjoying by these.

4. I believe this is one of the most significant information for me.
And i am glad studying your article. But should commentary on some basic issues,
The web site taste is great, the articles is in reality excellent :

5. Thanks for sharing your info. I truly appreciate your efforts and I will be waiting for your next write ups thanks once again.

6. Wow! In the end I got a webpage from where
I be capable of truly obtain helpful data regarding my study and
knowledge.

7. If some one wishes expert view about blogging and site-building after that i propose him/her to go to see
this website, Keep up the pleasant job.

8. I know this if off topic but I’m looking into starting my own weblog and was curious
what all is required to get set up? I’m assuming having a blog like
yours would cost a pretty penny? I’m not very web savvy so I’m not 100% sure.
Any recommendations or advice would be greatly appreciated.
Many thanks

9. An intriguing discussion is worth comment. I believe that you should write more
not discuss these topics. To the next! Cheers!!

10. It is not my first time to visit this site, i am browsing this site dailly and take nice information from here daily.

11. Hey I know this is off topic but I was wondering if you knew of
any widgets I could add to my blog that automatically tweet my
newest twitter updates. I’ve been looking for a plug-in like this for quite some time and was hoping maybe you would have
some experience with something like this. Please let me
know if you run into anything. I truly enjoy reading your blog

12. I have been absent for some time, but now I remember why I used to love this website. Thanks , I¦ll try and check back more often. How frequently you update your site?

13. When I initially commented I clicked the “Notify me when new comments are added” checkbox and
now each time a comment is added I get three emails with the same comment.
Is there any way you can remove people from that service?

Cheers!

14. Thanks for finally writing about >【BZOJ 1711】[Usaco2007 Open] Dining吃饭 –
Qizy’s Database <Liked it!

15. I feel that is among the so much significant information for me.