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

## Re:为什么大家爆搜也就16ms，我爆搜要47ms，这是什么情况，有人能分析下么，附代码

Posted by pirates at 2012-08-17 16:37:07 on Problem 1321
In Reply To:为什么大家爆搜也就16ms，我爆搜要47ms，这是什么情况，有人能分析下么，附代码 Posted by:scuwf at 2011-11-01 17:26:30
```> #include<stdio.h>
> #define MAX 9
> int hashrow[MAX];
> int hashcol[MAX];
> char map[MAX][MAX];
> int n,k,count;
> void DFS(int pre)
> {
> 	int i,j;
> 	if(k==0)
> 	{
> 		count++;
> 		return;
> 	}
> 	for(i=pre+1;i<n;i++)
> 	{
> 		for(j=0;j<n;j++)
> 		{
> 			if(map[i][j]=='#' && hashrow[i]==0 && hashcol[j]==0)
> 			{
> 				hashrow[i]=hashcol[j]=1;
> 				k--;
> 				DFS(i);
> 				k++;
> 				hashrow[i]=hashcol[j]=0;
> 			}
> 		}
> 	}
> }
> int main(void)
> {
> 	int i;
> 	while(scanf("%d%d",&n,&k) && n!=-1)
> 	{
> 		count=0;
> 		for(i=0;i<n;i++) scanf("%s",map[i]);
> 		DFS(-1);
> 		printf("%d\n",count);
> 	}
> 	return 0;
> }
```

Followed by:

User ID:
Title:

Content: