UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#211946#3815. 种树kedaya_123300ms1204kbC++863b2024-10-13 09:01:132024-10-13 12:52:29

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,k,sum;
ll vis[20][20];
struct Q{
	ll x;
	ll y;
}q[405];
bool check(ll x,ll y,ll cnt){
	for(ll i=1;i<=cnt;i++){
		if((q[i].x==x-1&&q[i].y==y)||(q[i].x==x+1&&q[i].y==y)){
			return  false;
		}
		if((q[i].x==x&&q[i].y==y+1)||(q[i].x==x&&q[i].y==y-1)){
			return false;
		}
	}
	return true;
}
void _dfs(ll cnt,ll jx,ll jy){
	if(cnt==k){
		sum++;
	}
	for(ll i=jy;i<=n;i++){
		if(check(jx,i,cnt)&&vis[jx][i]==0){
			q[cnt+1]={jx,i};
			vis[jx][i]=1;
			_dfs(cnt+1,jx,i);
			vis[jx][i]=0;
		}
	}
	for(ll i=jx+1;i<=n;i++){
		for(ll j=1;j<=m;j++){
			if(check(i,j,cnt)&&vis[i][j]==0){
				q[cnt+1]={i,j};
				vis[i][j]=1;
				_dfs(cnt+1,i,j);
				vis[i][j]=0;
			}
		}
	}
	return;
}
int main(){
	cin>>n>>m>>k;
	_dfs(0,1,1);
	cout<<sum;
	return 0;
}

详细

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

Test #1:

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

input:

2 2 1

output:

4

result:

ok 1 number(s): "4"

Test #2:

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

input:

2 3 2

output:

4

result:

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

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: 1204kb

input:

4 4 5

output:

304

result:

ok 1 number(s): "304"

Test #5:

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

input:

3 4 3

output:

41

result:

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

Test #6:

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

input:

3 5 2

output:

50

result:

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

Test #7:

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

input:

3 5 3

output:

66

result:

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

Test #8:

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

input:

3 5 4

output:

24

result:

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

Test #9:

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

input:

3 5 5

output:

3

result:

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

Test #10:

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

input:

4 3 5

output:

205

result:

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