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:谁给帮帮忙，看看代码哪里错了。感激不尽

Posted by xiaoyaowangchao at 2012-06-04 11:03:08 on Problem 1321
In Reply To:谁给帮帮忙，看看代码哪里错了。感激不尽 Posted by:tiankangwei at 2011-06-29 12:20:21
```>
>
> #include <iostream>
> using namespace std;
>
> bool col[10];
> char map[10][10];
> int n,k,res;
>
> void dfs( int r, int counter )
> {
> 	if ( r >= n  )
> 		return;
> 	if ( counter == k )
> 	{
> 		res++;
> 		return;
> 	}
> 	for ( int i = 0; i < n; i++ )
> 	{
> 		if ( map[r][i] == '#' && col[i] == 0 )
> 		{
> 			col[i] = 1;
> 			dfs(r+1,counter+1);
> 			col[i] = 0;
> 		}
> 	}
> 	dfs(r+1,counter);
> }
>
> int main()
> {
> 	while ( cin >> n >> k && ! (n == -1 && k == -1) )
> 	{
> 		getchar();
> 		memset(map,0,sizeof(map));
> 		memset(col,0,sizeof(col));
> 		for ( int i = 0; i < n; i++ )
> 			cin >> map[i];
> 	    res = 0;
> 		dfs(0,0);
> 		cout << res << endl;
> 	}
> 	return 0;
> }
```

Followed by: