UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#171405#1307. 传纸条heyuzhen10033ms23172kbC++592b2023-06-23 18:06:102023-06-23 19:59:57

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int a[51][51],f[51][51][51][51],n,m;
int Max(int i,int j,int k,int l){
	return max(max(max(i,j),k),l);} 
int main(){
	cin >> n >> m;
	for(int i = 1;i <= n;i++)
		for(int j = 1;j <= m;j++)
			cin >> a[i][j];
	for(int i = 1;i <= n;i++)
		for(int j = 1;j <= m;j++)
			for(int k = 1;k < i;k++)
				for(int l = j + 1;l <= m;l++)
					f[i][j][k][l] = Max(f[i - 1][j][k - 1][l],f[i - 1][j][k][l - 1],f[i][j - 1][k - 1][l],f[i][j - 1][k][l - 1]) + a[i][j] + a[k][l];
	cout << f[n][m - 1][n - 1][m];
	return 0;
}


Details

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

Test #1:

score: 9
Accepted
time: 2ms
memory: 3300kb

input:

3 3
0 9 9
6 1 8
2 3 0

output:

37

result:

ok single line: '37'

Test #2:

score: 9
Accepted
time: 4ms
memory: 23172kb

input:

50 50
0 41 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

5206

result:

ok single line: '5206'

Test #3:

score: 9
Accepted
time: 2ms
memory: 9080kb

input:

30 30
0 69 14 26 59 77 73 8 21 72 1 74 76 51 94 44 24 98 71 77 59 9 12 49 38 72 22 55 35 61
16 48 41...

output:

7745

result:

ok single line: '7745'

Test #4:

score: 9
Accepted
time: 1ms
memory: 23144kb

input:

50 50
0 41 85 72 38 80 69 65 68 96 22 49 67 51 61 63 87 66 24 80 83 71 60 64 52 90 60 49 31 23 99 94...

output:

13891

result:

ok single line: '13891'

Test #5:

score: 9
Accepted
time: 2ms
memory: 3564kb

input:

8 6
0 94 11 25 24 51
15 13 39 67 97 19
76 12 33 99 18 92
35 74 0 95 71 39
33 39 32 37 45 57
71 95 5 ...

output:

1382

result:

ok single line: '1382'

Test #6:

score: 9
Accepted
time: 8ms
memory: 21052kb

input:

50 45
0 69 99 65 34 34 0 91 72 90 36 39 34 76 81 66 50 2 45 76 83 91 100 66 52 57 71 29 63 21 26 32 ...

output:

13096

result:

ok single line: '13096'

Test #7:

score: 9
Accepted
time: 2ms
memory: 3420kb

input:

3 3
0 72 38
80 69 65
68 96 0

output:

450

result:

ok single line: '450'

Test #8:

score: 9
Accepted
time: 2ms
memory: 3320kb

input:

3 3
0 3 9
2 8 5
5 7 0

output:

34

result:

ok single line: '34'

Test #9:

score: 9
Accepted
time: 4ms
memory: 5116kb

input:

18 20
0 32 89 70 89 55 71 79 40 10 64 80 30 19 62 67 98 42 8 32
57 27 22 1 38 89 52 74 43 8 2 65 82 ...

output:

4419

result:

ok single line: '4419'

Test #10:

score: 9
Accepted
time: 0ms
memory: 3944kb

input:

12 12
0 70 33 63 29 99 58 94 52 13 35 99
46 57 71 23 17 3 94 48 77 18 83 11
83 25 59 62 2 78 86 7 94...

output:

3021

result:

ok single line: '3021'

Test #11:

score: 9
Accepted
time: 6ms
memory: 18104kb

input:

40 50
0 56 55 87 87 31 77 47 63 55 18 81 35 0 14 5 46 34 94 7 11 97 74 37 34 7 65 45 62 69 83 38 85 ...

output:

12203

result:

ok single line: '12203'