UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#211945#3815. 种树Fisher201301ms1200kbC++621b2024-10-13 09:01:092024-10-13 12:52:25

answer

#include <bits/stdc++.h>
using namespace std;
int cnt = 0, n, m, vis[18][18];
void DFS(int i, int j, int num){
	if(num == 0){
		for(int x = 1; x <= n; x++){
			for(int y = 1; y <= m; y++){
				cout << vis[x][y] << " ";
			}
			cout << endl;
		}
		cnt++;
		return;
	}
	int x = i, y = j;
	while(x <= n){
		if (!vis[x][y] && !vis[x + 1][y] && !vis[x - 1][y] && !vis[x][y + 1] && !vis[x][y - 1]){
			vis[x][y] = 1;
			DFS(x, y, num - 1);
			vis[x][y] = 0;
		}
		y++;
		if(y == m + 1){
			y = 1, x++;
		}
	}
}
int main() {
	int k;
	cin >> n >> m >> k;
	DFS(1, 1, k);
	cout << cnt;
	return 0;
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 1196kb

input:

2 2 1

output:

1 0 
0 0 
0 1 
0 0 
0 0 
1 0 
0 0 
0 1 
4

result:

wrong answer 1st numbers differ - expected: '4', found: '1'

Test #2:

score: 0
Wrong Answer
time: 1ms
memory: 1196kb

input:

2 3 2

output:

1 0 1 
0 0 0 
1 0 0 
0 1 0 
1 0 0 
0 0 1 
0 1 0 
1 0 0 
0 1 0 
0 0 1 
0 0 1 
1 0 0 
0 0 1 
0 1 0 
0 ...

result:

wrong answer 1st numbers differ - expected: '8', found: '1'

Test #3:

score: 0
Wrong Answer
time: 0ms
memory: 1200kb

input:

4 4 2

output:

1 0 1 0 
0 0 0 0 
0 0 0 0 
0 0 0 0 
1 0 0 1 
0 0 0 0 
0 0 0 0 
0 0 0 0 
1 0 0 0 
0 1 0 0 
0 0 0 0 
0...

result:

wrong answer 1st numbers differ - expected: '96', found: '1'

Test #4:

score: 0
Wrong Answer
time: 0ms
memory: 1196kb

input:

4 4 5

output:

1 0 1 0 
0 1 0 1 
1 0 0 0 
0 0 0 0 
1 0 1 0 
0 1 0 1 
0 0 1 0 
0 0 0 0 
1 0 1 0 
0 1 0 1 
0 0 0 0 
1...

result:

wrong answer 1st numbers differ - expected: '304', found: '1'

Test #5:

score: 0
Wrong Answer
time: 0ms
memory: 1200kb

input:

3 4 3

output:

1 0 1 0 
0 1 0 0 
0 0 0 0 
1 0 1 0 
0 0 0 1 
0 0 0 0 
1 0 1 0 
0 0 0 0 
1 0 0 0 
1 0 1 0 
0 0 0 0 
0...

result:

wrong answer 1st numbers differ - expected: '84', found: '1'

Test #6:

score: 0
Wrong Answer
time: 0ms
memory: 1196kb

input:

3 5 2

output:

1 0 1 0 0 
0 0 0 0 0 
0 0 0 0 0 
1 0 0 1 0 
0 0 0 0 0 
0 0 0 0 0 
1 0 0 0 1 
0 0 0 0 0 
0 0 0 0 0 
1...

result:

wrong answer 1st numbers differ - expected: '83', found: '1'

Test #7:

score: 0
Wrong Answer
time: 0ms
memory: 1200kb

input:

3 5 3

output:

1 0 1 0 1 
0 0 0 0 0 
0 0 0 0 0 
1 0 1 0 0 
0 1 0 0 0 
0 0 0 0 0 
1 0 1 0 0 
0 0 0 1 0 
0 0 0 0 0 
1...

result:

wrong answer 1st numbers differ - expected: '215', found: '1'

Test #8:

score: 0
Wrong Answer
time: 0ms
memory: 1200kb

input:

3 5 4

output:

1 0 1 0 1 
0 1 0 0 0 
0 0 0 0 0 
1 0 1 0 1 
0 0 0 1 0 
0 0 0 0 0 
1 0 1 0 1 
0 0 0 0 0 
1 0 0 0 0 
1...

result:

wrong answer 1st numbers differ - expected: '276', found: '1'

Test #9:

score: 0
Wrong Answer
time: 0ms
memory: 1200kb

input:

3 5 5

output:

1 0 1 0 1 
0 1 0 1 0 
0 0 0 0 0 
1 0 1 0 1 
0 1 0 0 0 
1 0 0 0 0 
1 0 1 0 1 
0 1 0 0 0 
0 0 1 0 0 
1...

result:

wrong answer 1st numbers differ - expected: '174', found: '1'

Test #10:

score: 0
Wrong Answer
time: 0ms
memory: 1196kb

input:

4 3 5

output:

1 0 1 
0 1 0 
1 0 1 
0 0 0 
1 0 1 
0 1 0 
1 0 0 
0 1 0 
1 0 1 
0 1 0 
1 0 0 
0 0 1 
1 0 1 
0 1 0 
0 ...

result:

wrong answer 1st numbers differ - expected: '18', found: '1'