Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么将cnt从500改到1000就对了???代码: #include<cstdio> #include<cstring> const int N=5000+5; using namespace std; int g[10][20]; int head[N],nxt[N],to[N],cn; int link[N]; int n,t,p,q,ans,cnt=1000; bool vis[N]; void init(){ ans=cn=0; memset(link,0,sizeof(link)); memset(head,0,sizeof(head)); memset(nxt,0,sizeof(nxt)); memset(to,0,sizeof(to)); } void create(int u,int v){ cn++; to[cn]=v; nxt[cn]=head[u]; head[u]=cn; } bool find(int x){ int v; for(int i=head[x];i;i=nxt[i]){ v=to[i]; if(!vis[v]){ vis[v]=true; if((!link[v]) || (find(link[v]))){ link[v]=x; return true; } } } return false; } int main(){ for(int i=1;i<=7;i++) for(int j=1;j<=12;j++) g[i][j]=++cnt; while(scanf("%d",&n)==1){ init(); for(int i=1;i<=n;i++){ scanf("%d",&t); for(int j=1;j<=t;j++){ scanf("%d%d",&p,&q); create(i,g[p][q]); } } for(int i=1;i<=n;i++){ memset(vis,false,sizeof(vis)); if(find(i)) ans++; } printf("%d\n",ans); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator