| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
回溯 函数递归 不模拟 都能0s呢……只是不小心贡献了一个RE,怎么前辈讨论消减时间这么激烈??#include <iostream>
using namespace std;
char hl[9],maze[9][9];
int n,ii;
void search(const int k,const int bian)
{
int i,j;
for (i=bian-1;i>k-2;i--)
{
for (j=0;j<n;j++)
if (maze[i][j]=='#' && hl[j]==0)
if (i && k>1)
{
hl[j]=1;
search(k-1,i);
hl[j]=0;
}
else
ii++;
}
}
int main()
{
int k,i;
while(1)
{
cin>>n>>k;
if (n==-1)
break;
else
{
memset(hl,0,sizeof(hl));
for (i=0;i<n;i++)
scanf("%s",maze[i]);
ii=0;
search(k,n);
cout<<ii<<endl;
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator