Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

是bug吗??

Posted by 201321131067 at 2015-10-23 20:22:29 on Problem 2239
右边可能的点的数量有:12*7=72种可能
为什么要开数组时要开到305才能过,否则就WA??
代码如下:

////2239 Selecting Courses(匈牙利算法)
#include<stdio.h>
#include<string.h>

int check[85],map[305][85],n,match[85],ref;
//为什么这个地方map[],check[],match[]都要开到305才能过??

bool dfs(int u){
	for(int i=1;i<=72;i++){//为什么这个地方的72要改为305??
		if(map[u][i]>0&&check[i]==0){
			check[i]=1;
			if(match[i]==-1||dfs(match[i])){
				match[i]=u;
				return true;
			}
		}
	}
	return false;
}
void pro(){
	for(int i=1;i<=n;i++){
		memset(check,0,sizeof(check));
		if(dfs(i)) ref++;
	}
}
int main(){
	int t,p,q;
	while(~scanf("%d",&n)){
		memset(map,0,sizeof(map));
		memset(match,-1,sizeof(match));
		ref=0;
		for(int i=1;i<=n;i++){
			scanf("%d",&t);
			for(int j=1;j<=t;j++){
				scanf("%d%d",&p,&q);
				map[i][p*12-12+q]=1;
				//map[p*12-12+q][i]=1;
			}
		}
		pro();
		printf("%d\n",ref);
	}
	return 0;
}

我还只是喳喳,求解答!!

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator