| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 479837 | MilosMilutinovic | Maxcomp (info1cup18_maxcomp) | C++14 | 193 ms | 28508 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
const int N = 1005;
int n, m;
int a[N][N];
int pref1[N][N];
int pref2[N][N];
int pref3[N][N];
int pref4[N][N];
int main()
{
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
scanf("%d", &a[i][j]);
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
pref1[i][j] = a[i][j] - i - j;
if (i > 0) pref1[i][j] = min(pref1[i][j], pref1[i - 1][j]);
if (j > 0) pref1[i][j] = min(pref1[i][j], pref1[i][j - 1]);
}
}
for (int i = n - 1; i >= 0; i--) {
for (int j = 0; j < m; j++) {
pref2[i][j] = a[i][j] + i - j;
if (i + 1 < n) pref2[i][j] = min(pref2[i][j], pref2[i + 1][j]);
if (j > 0) pref2[i][j] = min(pref2[i][j], pref2[i][j - 1]);
}
}
for (int i = 0; i < n; i++) {
for (int j = m - 1; j >= 0; j--) {
pref3[i][j] = a[i][j] - i + j;
if (i > 0) pref3[i][j] = min(pref3[i][j], pref3[i - 1][j]);
if (j + 1 < m) pref3[i][j] = min(pref3[i][j], pref3[i][j + 1]);
}
}
for (int i = n - 1; i >= 0; i--) {
for (int j = m - 1; j >= 0; j--) {
pref4[i][j] = a[i][j] + i + j;
if (i + 1 < n) pref4[i][j] = min(pref4[i][j], pref4[i + 1][j]);
if (j + 1 < m) pref4[i][j] = min(pref4[i][j], pref4[i][j + 1]);
}
}
int ans = -1;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
ans = max(ans, a[i][j] - i - j - pref1[i][j] - 1);
ans = max(ans, a[i][j] + i - j - pref2[i][j] - 1);
ans = max(ans, a[i][j] - i + j - pref3[i][j] - 1);
ans = max(ans, a[i][j] + i + j - pref4[i][j] - 1);
}
}
cout << ans << '\n';
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
