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

搞错大小写,醉了。

Posted by 983543692 at 2016-06-11 17:38:56 on Problem 1698
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxw=57*7,maxn=27;
bool map[maxw][maxn];
int cnt;
bool visit[maxn];
int link[maxn][57],num[maxn];
int cntnum[maxn];
int t,n,w;
bool dfs(int x)
{
	for(int i=1;i<=n;i++)
	{
		if(!visit[i]&&map[x][i])
		{
			visit[i]=true;
			if(cntnum[i]<num[i])
			{
				link[i][cntnum[i]++]=x;
				return true;
			}else for(int j=0;j<num[i];j++)
			{
				if(dfs(link[i][j]))
				{
					link[i][j]=x;
					return true;
				}
			}
			
		}
	}
	return false;
}
void Hungary()
{
	memset(link,0,sizeof(link));
	memset(cntnum,0,sizeof(cntnum));
	cnt=0;
	for(int i=1;i<maxw;i++)
	{
		memset(visit,0,sizeof(visit));
		if(dfs(i))cnt++;
	}
}
int main()
{
	scanf("%d",&t);
	while(t--)
	{
		int sum=0;
		memset(map,0,sizeof(map));
		scanf("%d",&n);
		for(int i=1;i<=n;++i)
		{
			int day[8];
			for(int j=1;j<=7;j++)
			{
				scanf("%d",&day[j]);
			}
			scanf("%d",&num[i]);
			sum+=num[i];
		    scanf("%d",&w);
		    for(int l=1;l<=7;l++)
		   {
			    if(day[l])
			   {
			   	  if(l!=7)
				   for(int j=l+1;j<=w*7;j+=7)
				  {
					  map[j][i]=true;
				  }
				  else for(int j=1;j<=w*7;j+=7)
				  {
				  	map[j][i]=true;
				  }
			   }
		   }
		}
		Hungary();
		if(cnt>=sum)printf("Yes\n");
		else printf("No\n");
	 } 
}

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