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

大牛们帮我看看这段代码,很短,老师WA

Posted by 200830740509 at 2009-08-11 20:46:59 on Problem 1321
#include <cstdio>
#include <algorithm>
#include <functional>
#include<cstdlib>
#include<iostream>
#include<cstring>
using namespace std;
char a[8][8]; 
bool can[8];
int n,k;
long c;
void dfs(int i,int num)
{
	for(int j=0;j<n;j++)
	{
		if(a[i][j]=='#'&&can[j]==true)
		{
			can[j]=false;
			num--;
			if(i+1<n&&num>0)
				dfs(i+1,num);
			else if(num==0)
				c++;
			num++;
			can[j]=true;
		}
	}		
}
int main()
{
	while(scanf("%d%d",&n,&k)!=EOF)
	{
		if(n==-1&&k==-1)
			break;
		for(int i=0;i<8;i++)
			can[i]=true;
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				cin>>a[i][j];
		c=0;			
		for(int i=0;i<n;i++)
		 	dfs(i,k);
		cout<<c<<endl;
	}
	system("pause");
	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