UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#212086#3815. 种树seven_0710010ms1200kbC++1.5kb2024-10-13 11:06:562024-10-13 12:55:57

answer

#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
int a[17][17];
bool check(int n,int m){
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= m;j++){
			if(a[i][j]==1){
				if(a[i-1][j]||a[i][j-1]||a[i+1][j]||a[i][j+1])	return false;
			}
		}
	}
	return true;
}
int main(){
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	ll x,y,z; cin >> x >> y >> z;
	for(int n = 1;n <= 16;n++){
		for(int m = 1;m <= 16;m++){
			if(n*m>16)	break;
			for(int k = 1;k <= 5;k++){
				int cnt = 0;
				for(int a1 = 1;a1 <= n*m;a1++){
					a[(a1-1)/m+1][(a1-1)%m+1]=1;
					for(int a2 = a1+1;a2 <= n*m;a2++){
						if(k<2)	continue;
						a[(a2-1)/m+1][(a2-1)%m+1]=1;
						for(int a3 = a2+1;a3 <= n*m;a3++){
							if(k<3)	continue;
							a[(a3-1)/m+1][(a3-1)%m+1]=1;
							for(int a4 = a3+1;a4 <= n*m;a4++){
								if(k<4)	continue;
								a[(a4-1)/m+1][(a4-1)%m+1]=1;
								for(int a5 = a4+1;a5 <= n*m;a5++){
									if(k<5)	continue;
									a[(a5-1)/m+1][(a5-1)%m+1]=1;
									if(check(n,m))	cnt++;
									a[(a5-1)/m+1][(a5-1)%m+1]=0;
								}
								if(k==4)	if(check(n,m))	cnt++;
								a[(a4-1)/m+1][(a4-1)%m+1]=0;
							}
							if(k==3)	if(check(n,m))	cnt++;
							a[(a3-1)/m+1][(a3-1)%m+1]=0;
						}
						if(k==2)	if(check(n,m))	cnt++;
						a[(a2-1)/m+1][(a2-1)%m+1]=0;
					}
					if(k==1)	if(check(n,m))	cnt++;
					a[(a1-1)/m+1][(a1-1)%m+1]=0;
				}
				if(n==x&&m==y&&k==z){
					cout << cnt;
					exit(0);
				}
			}
		}
	}
	return 0;
}

详细

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

Test #1:

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

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: 4ms
memory: 1200kb

input:

4 4 5

output:

304

result:

ok 1 number(s): "304"

Test #5:

score: 10
Accepted
time: 2ms
memory: 1200kb

input:

3 4 3

output:

84

result:

ok 1 number(s): "84"

Test #6:

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

input:

3 5 2

output:

83

result:

ok 1 number(s): "83"

Test #7:

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

input:

3 5 3

output:

215

result:

ok 1 number(s): "215"

Test #8:

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

input:

3 5 4

output:

276

result:

ok 1 number(s): "276"

Test #9:

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

input:

3 5 5

output:

174

result:

ok 1 number(s): "174"

Test #10:

score: 10
Accepted
time: 3ms
memory: 1196kb

input:

4 3 5

output:

18

result:

ok 1 number(s): "18"

Extra Test:

score: 0
Extra Test Passed