-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path011.cpp
More file actions
55 lines (49 loc) · 1.22 KB
/
011.cpp
File metadata and controls
55 lines (49 loc) · 1.22 KB
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
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int r = 20;
int c = 20;
int matrix[20][20];
for (int i = 0; i < r; ++i) {
for (int j = 0; j < c; ++j) {
cin >> matrix[i][j];
}
}
int best = 0;
for (int a = 0; a < r; a++) {
for (int b = 0; b < c; b++) {
if (b + 3 < 20) {
int curr = matrix[b][a] * matrix[b + 1][a] * matrix[b + 2][a] *
matrix[b + 3][a];
if (best < curr) {
best = curr;
}
}
if (a + 3 < 20) {
int curr = matrix[b][a] * matrix[b][a + 1] * matrix[b][a + 2] *
matrix[b][a + 3];
if (best < curr) {
best = curr;
}
}
if (a + 3 < 20 && b + 3 < 20) {
int curr = matrix[b][a] * matrix[b + 1][a + 1] * matrix[b + 2][a + 2] *
matrix[b + 3][a + 3];
if (best < curr) {
best = curr;
}
}
if (b + 3 < 20 && a >= 3) {
int curr = matrix[b][a] * matrix[b + 1][a - 1] * matrix[b + 2][a - 2] *
matrix[b + 3][a - 3];
if (best < curr) {
best = curr;
}
}
}
}
cout << best << "\n";
}