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 team162 at 2010-12-09 17:43:04 on Problem 1321
//============================================================================
// Name        : PKU-ACM.cpp
// Author      : Jarvis
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <vector>
using namespace std;
#define __int64 long long


char map[8][8];
int can=0;
int res=0;

void dfs(int n,int k,int l)
{
	if (l>=n||k<=0)
		return;
	for(int i=0;i<n;++i)
	{
		if(map[l][i]=='#'&&(can&(1<<i))==0)
		{
			can|=(1<<i);
			if(k-1==0)
				++res;
			else
				dfs(n,k-1,l+1);
			can&=~(1<<i);
			
		}
	}
	if(k<n-l)
		dfs(n,k,l+1);

	}
int main()
{

	int n,k;
	while(scanf("%d%d",&n,&k)&&n!=-1&&k!=-1)
	{
		for(int i=0;i<n;++i)
			scanf("%s",map[i]);
		res=0;
		can=0;

		dfs(n,k,0);
		printf("%d\n",res);
	}
	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