[POI2011]PRO-Programming Contest
作者:互联网
Bzoj2557
#include<bits/stdc++.h> #define int long long using namespace std; const int N=555; const int M=3e5+7; int n,m,r,t,T; int _; int head[N],nxt[M],to[M]; void add(int x,int y) { _++; nxt[_]=head[x]; head[x]=_; to[_]=y; return ; } bool vis[N],used[N]; int match[N]; bool find(int x) { for(int i=head[x];i;i=nxt[i]) { int y=to[i]; if(used[y]) continue; used[y]=1; if(!match[y]||find(match[y])) { match[y]=x; return 1; } } return 0; } int ans1,ans2; signed main() { ios::sync_with_stdio(false); cin>>n>>m>>r>>t>>T; while(T--) { int x,y; cin>>x>>y; add(x,y); } for(int i=1;i<=(t/r);i++) { for(int j=1;j<=n;j++) { if(!vis[j]) { memset(used,0,sizeof(used)); if(find(j)) { ans1++; ans2+=i; } else vis[j]=1; } } } cout<<ans1<<' '<<ans2*r; return 0; }
标签:nxt,head,used,return,int,PRO,POI2011,Programming,match 来源: https://www.cnblogs.com/Hehe-0/p/15517998.html