UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#211992#3815. 种树yangyiming1001ms1284kbC++1019b2024-10-13 09:42:202024-10-13 12:54:26

answer

#include<bits/stdc++.h>
using namespace std;
int flage[20][20];
map<string , int> mp;
long long ans = 0;
int n , m , k;
void dfs(int dep , int x , int y , string s)
{
	if (dep == k + 1)
	{
		if (mp[s] == 0)
		{
			ans++;
//			for (int i = 1;i <= n;i++)
//			{
//				for (int j = 1;j <= m;j++)
//				{
//					cout << flage[i][j];
//				}
//				cout << "\n";
//			}
			//cout << "\n";
			mp[s] = 1;
		}
		return ;
	}
	if (x > n or y > m)
	{
		return ;
	}
	if (flage[x-1][y] == 1 or flage[x][y-1] == 1 or flage[x][y+1] == 1 or flage[x+1][y] == 1 or flage[x][y] == 1)
	{
		flage[x][y] = 0;
		string tt = s + "0";
		if (m == y)dfs(dep,x+1,1,tt);
		else dfs(dep,x,y+1,tt);
	}
	else
	{
		flage[x][y] = 1;
		string t = s + "1";
		if (m == y)dfs(dep+1,x+1,1,t);
		else dfs(dep+1,x,y+1,t);
		string tt = s + "0";
		flage[x][y] = 0;
		if (m == y)dfs(dep,x+1,1,tt);
		else dfs(dep,x,y+1,tt);
	}
	
}
int main()
{
	cin >> n >> m >> k;
	dfs(1,1,1,"");
	cout << ans;
	return 0;
}

详细

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

Test #1:

score: 10
Accepted
time: 0ms
memory: 1248kb

input:

2 2 1

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 10
Accepted
time: 0ms
memory: 1248kb

input:

2 3 2

output:

8

result:

ok 1 number(s): "8"

Test #3:

score: 10
Accepted
time: 0ms
memory: 1264kb

input:

4 4 2

output:

96

result:

ok 1 number(s): "96"

Test #4:

score: 10
Accepted
time: 0ms
memory: 1284kb

input:

4 4 5

output:

304

result:

ok 1 number(s): "304"

Test #5:

score: 10
Accepted
time: 0ms
memory: 1260kb

input:

3 4 3

output:

84

result:

ok 1 number(s): "84"

Test #6:

score: 10
Accepted
time: 0ms
memory: 1260kb

input:

3 5 2

output:

83

result:

ok 1 number(s): "83"

Test #7:

score: 10
Accepted
time: 0ms
memory: 1276kb

input:

3 5 3

output:

215

result:

ok 1 number(s): "215"

Test #8:

score: 10
Accepted
time: 0ms
memory: 1284kb

input:

3 5 4

output:

276

result:

ok 1 number(s): "276"

Test #9:

score: 10
Accepted
time: 0ms
memory: 1272kb

input:

3 5 5

output:

174

result:

ok 1 number(s): "174"

Test #10:

score: 10
Accepted
time: 1ms
memory: 1252kb

input:

4 3 5

output:

18

result:

ok 1 number(s): "18"

Extra Test:

score: 0
Extra Test Passed