This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define inf -1e9
int main(void) {
int n, m;
cin >> n >> m;
vector <vector <int> > g(n, vector <int> (m));
function <int()> get=[&]() {
int ans = -1e9;
vector <int> mx(m, 1e9);
for(int i = 0; i< n; i ++) {
for(int j = 0; j < m; j ++) {
if(j) {
mx[j] = min({mx[j-1], mx[j], g[i][j] - i - j});
}else {
mx[j] = min({mx[j], g[i][j] - i - j});
}
}
for(int j = 0; j < m; j ++) {
ans = max(ans, g[i][j] - mx[j] - 1 - i - j);
}
}
return ans;
};
for(int i = 0; i < n; i ++) {
for(int j = 0; j < m; j ++) cin >> g[i][j];
}
int getmx = -1e9;
getmx = max(getmx, get());
for(int i = 0; i < n; i ++) {
reverse(g[i].begin(), g[i].end());
}
getmx = max(getmx, get());
for(int i = 0; i < (n >> 1); i ++) {
for(int j = 0; j < m; j ++) {
swap(g[n - (i + 1)][j], g[i][j]);
}
}
getmx = max(getmx, get());
for(int i = 0; i < n; i ++) {
reverse(g[i].begin(), g[i].end());
}
getmx = max(getmx, get());
cout << getmx;
return false;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |