ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#211968 | #3815. 种树 | xxc | 100 | 0ms | 1204kb | C++ | 1.2kb | 2024-10-13 09:25:08 | 2024-10-13 12:53:49 |
answer
#include<iostream>
#include<cstring>
using namespace std;
int n,m,k;
int visited[20][20],ans[20][20];
int px[5]={0,-1,0,0,1};
int py[5]={0,0,-1,1,0};
int f(int x,int y,int l)
{
if(visited[x][y])
{
return 0;
}
if(l==k-1)
{
return 1;
}
// if(ans[x][y]!=-1)
// {
// return ans[x][y];
// }
int t[5];
for(int i=0;i<5;i++)
{
t[i]=visited[px[i]+x][py[i]+y];
visited[px[i]+x][py[i]+y]=1;
}
int s=0;
int tv[20][20];
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
// if(ans[i][j]!=-1)
// {
// s+=ans[i][j];
// }else
// {
s+=f(i,j,l+1);
// }
tv[i][j]=visited[i][j];
visited[i][j]=1;
}
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
visited[i][j]=tv[i][j];
}
}
for(int i=0;i<5;i++)
{
visited[px[i]+x][py[i]+y]=t[i];
}
return s;
}
int c()
{
int s=1;
for(int i=1;i<=k;i++)
{
s*=i;
}
return s;
}
int main()
{
cin>>n>>m>>k;
// for(int i=1;i<=n;i++)
// {
// for(int j=1;j<=m;j++)
// {
// ans[i][j]=-1;
// }
// }
int s=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
s+=f(i,j,0);
visited[i][j]=1;
}
}
cout<<s<<endl;
return 0;
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1200kb
input:
2 2 1
output:
4
result:
ok 1 number(s): "4"
Test #2:
score: 10
Accepted
time: 0ms
memory: 1200kb
input:
2 3 2
output:
8
result:
ok 1 number(s): "8"
Test #3:
score: 10
Accepted
time: 0ms
memory: 1200kb
input:
4 4 2
output:
96
result:
ok 1 number(s): "96"
Test #4:
score: 10
Accepted
time: 0ms
memory: 1200kb
input:
4 4 5
output:
304
result:
ok 1 number(s): "304"
Test #5:
score: 10
Accepted
time: 0ms
memory: 1196kb
input:
3 4 3
output:
84
result:
ok 1 number(s): "84"
Test #6:
score: 10
Accepted
time: 0ms
memory: 1200kb
input:
3 5 2
output:
83
result:
ok 1 number(s): "83"
Test #7:
score: 10
Accepted
time: 0ms
memory: 1196kb
input:
3 5 3
output:
215
result:
ok 1 number(s): "215"
Test #8:
score: 10
Accepted
time: 0ms
memory: 1204kb
input:
3 5 4
output:
276
result:
ok 1 number(s): "276"
Test #9:
score: 10
Accepted
time: 0ms
memory: 1204kb
input:
3 5 5
output:
174
result:
ok 1 number(s): "174"
Test #10:
score: 10
Accepted
time: 0ms
memory: 1204kb
input:
4 3 5
output:
18
result:
ok 1 number(s): "18"
Extra Test:
score: 0
Extra Test Passed