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

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:

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