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 |
没搞懂怎么就是WA,各位给看看#include <iostream> #include <cstdio> const int maxn = 10; char chessboard[maxn][maxn+1]; int n, k; bool visit[maxn] = {}; int dfs(int row, int amount){ if(amount == 0){ return 1; } int res = 0; for(int i=0; i < n; ++i){ if(chessboard[row][i] == '#' && !visit[i]){ visit[i] = true; res += dfs(row+1, amount-1); visit[i] = false; } } return res; } int main(){ while(scanf("%d%d", &n, &k), n != -1){ for(int i=0; i < n; ++i){ scanf("%s", chessboard[i]); } int ans = 0; for(int i=0; i <= n-k; ++i){ ans += dfs(i, k); } printf("%d\n", ans); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator