-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path14500.cpp
59 lines (45 loc) · 1.09 KB
/
14500.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <stdio.h>
int Xblocks[13][4]={{0,1,2,2},{0,0,0,1},{0,0,1,2},{0,1,1,1},{0,1,1,2},{0,0,1,1},{0,0,0,1},{0,1,1,2},{0,1,1,1},{0,1,1,2},{0,1,2,3},{0,0,0,0},{0,0,1,1}};
int Yblocks[13][4]={{0,0,0,1},{0,1,2,0},{0,1,1,1},{0,0,-1,-2},{0,0,1,1},{0,-1,-1,-2},{0,1,2,1},{0,0,-1,0},{0,0,-1,1},{0,0,1,0},{0,0,0,0},{0,1,2,3},{0,1,0,1}};
int map[500][500];
int n,m;
int result=0;
void calculateSum(int x, int y, int form, int sym){
int sum=0;
for(int i=0;i<4;i++){
int nextX=x+Xblocks[form][i];
int nextY;
if(sym==0) nextY=y+Yblocks[form][i];
else nextY=y-Yblocks[form][i];
//printf("%d %d\n",nextX, nextY);
if(nextX>=n || nextX<0 || nextY>=m || nextY<0){
break;
}
sum+=map[nextX][nextY];
}
if(sum>result) result=sum;
return;
}
void tetris(){
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
for(int k=0;k<13;k++){
calculateSum(i,j,k,0);
if(k<6){
calculateSum(i,j,k,1);
}
}
}
}
return;
}
int main(){
scanf("%d %d",&n,&m);
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
scanf("%d",&map[i][j]);
}
}
tetris();
printf("%d\n",result);
}