ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#211927 | #3815. 种树 | Rainxcy | 100 | 4ms | 1192kb | C++ | 654b | 2024-10-13 08:49:18 | 2024-10-13 12:51:16 |
answer
#include <bits/stdc++.h>
using namespace std;
int n,m,k;
bool vis[20][20];
long long ans;
void dfs(int deep,int x,int y);
int main()
{
scanf("%d %d %d",&n,&m,&k);
dfs(1,1,1);
printf("%lld",ans);
return 0;
}
void dfs(int deep,int x,int y){
if(deep>k){
ans++;
return;
}
int j;
for(int i=x;i<=n;i++){
if(i==x) j=y;
else j=1;
for(;j<=m;j++){
if(!vis[i][j]&&!vis[i+1][j]&&!vis[i][j+1]&&!vis[i-1][j]&&!vis[i][j-1]){
vis[i][j]=1;
dfs(deep+1,i,j);
vis[i][j]=0;
}
}
}
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1192kb
input:
2 2 1
output:
4
result:
ok 1 number(s): "4"
Test #2:
score: 10
Accepted
time: 1ms
memory: 1192kb
input:
2 3 2
output:
8
result:
ok 1 number(s): "8"
Test #3:
score: 10
Accepted
time: 1ms
memory: 1188kb
input:
4 4 2
output:
96
result:
ok 1 number(s): "96"
Test #4:
score: 10
Accepted
time: 1ms
memory: 1192kb
input:
4 4 5
output:
304
result:
ok 1 number(s): "304"
Test #5:
score: 10
Accepted
time: 0ms
memory: 1188kb
input:
3 4 3
output:
84
result:
ok 1 number(s): "84"
Test #6:
score: 10
Accepted
time: 0ms
memory: 1192kb
input:
3 5 2
output:
83
result:
ok 1 number(s): "83"
Test #7:
score: 10
Accepted
time: 0ms
memory: 1192kb
input:
3 5 3
output:
215
result:
ok 1 number(s): "215"
Test #8:
score: 10
Accepted
time: 0ms
memory: 1188kb
input:
3 5 4
output:
276
result:
ok 1 number(s): "276"
Test #9:
score: 10
Accepted
time: 0ms
memory: 1192kb
input:
3 5 5
output:
174
result:
ok 1 number(s): "174"
Test #10:
score: 10
Accepted
time: 1ms
memory: 1188kb
input:
4 3 5
output:
18
result:
ok 1 number(s): "18"
Extra Test:
score: 0
Extra Test Passed