Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## Re:简单

Posted by PioPio at 2016-12-17 11:58:27 on Problem 1321
In Reply To:简单 Posted by:when at 2016-11-26 11:12:49
> #include <iostream>
> #include <cstring>
> using namespace std;
>
> const int ROW = 10;
> const int COL = 10;
>
> int book[COL];
> char chess[ROW][COL];
> int step, n;
> long long  sum;
>
>
> void DFS(char chess[][COL], int row,int k) {
> 	if (row > n)
> 		return;
> 	if (k == step) {
> 		sum++;
> 		return;
> 	}
>
> 	for (int j = 1; j <= 2; j++) {
> 		if (j == 1)
> 			DFS(chess, row + 1, k); //每一行都有两种选择，放或不放
> 		if (j == 2) {
> 			for (int i = 0; i < n; i++) {
> 				if (book[i] == 0 && chess[row][i] == '#') {
> 					book[i] = 1;
> 					DFS(chess, row + 1, k + 1);
> 					book[i] = 0;
> 				}
> 			}
> 		}
> 	}
> }
>
>
> int main() {
> 	while (cin >> n >> step) {
> 		sum = 0;
> 		cin.get();
> 		if (n == -1 && step == -1)
> 			break;
> 		for (int i = 0; i < n; i++)
> 			cin >> chess[i];
>
> 			DFS(chess, 0, 0);
>
>
>
> 		cout << sum << endl;
> 	}
> }

Followed by: