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 |
谁给帮帮忙,看看代码哪里错了。感激不尽#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:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator