Submission #496979

# Submission time Handle Problem Language Result Execution time Memory
496979 2021-12-22T07:57:35 Z kingline Maxcomp (info1cup18_maxcomp) C++17
0 / 100
1 ms 332 KB
/*#pragma GCC optimize("O3")
#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")*/
#include <bits/stdc++.h>
#pragma GCC optimize ("unroll-loops,Ofast,O3")
#pragma GCC target("avx,avx2,fma")
//#define file(data) freopen(data".in", "r", stdin); freopen(data".out", "w", stdout);
#define pb push_back
//#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(data) data.begin() , data.end()
#define endl '\n'
//freopen("nenokku_easy.in", "r", stdin);
//freopen("nenokku_easy.out", "w", stdout);
#define int long long
#define pii pair < int, int >
#define pll pair < long long, long long >

using namespace std;

const int N = 1e3 + 5;
const int lg = 21;

int n, m, a[N][N], up[N][N], down[N][N], righ[N][N], lef[N][N];

void leftt(int i, int j, int val) {
    if(lef[i][j] > val || i > n || i < 1 || j > m || j < 1) return;
    lef[i][j] = val;
    leftt(i + 1, j, val - 1);
    leftt(i - 1, j, val - 1);
    leftt(i, j - 1, val - 1);
}

void rightt(int i, int j, int val) {
    if(righ[i][j] > val || i > n || i < 1 || j > m || j < 1) return;
    righ[i][j] = val;
    rightt(i + 1, j, val - 1);
    rightt(i - 1, j, val - 1);
    rightt(i, j + 1, val - 1);
}

void upp(int i, int j, int val) {
    if(up[i][j] > val || i > n || i < 1 || j > m || j < 1) return;
    up[i][j] = val;
    upp(i - 1, j, val - 1);
    upp(i, j - 1, val - 1);
    upp(i, j + 1, val - 1);
}

void downn(int i, int j, int val) {
    if(down[i][j] > val || i > n || i < 1 || j > m || j < 1) return;
    down[i][j] = val;
    downn(i + 1, j, val - 1);
    downn(i, j - 1, val - 1);
    downn(i, j + 1, val - 1);
}

main() {
    //file("pieaters");
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            cin >> a[i][j];
            up[i][j] = lef[i][j] = down[i][j] = righ[i][j] = a[i][j] - 1;
        }
    }
    for(int i = 1; i <= n; i++) {
        leftt(i, m, a[i][m] - 1);
        rightt(i, m, a[i][m] - 1);
    }
    for(int i = 1; i <= m; i++) {
        upp(n, i, a[n][i] - 1);
        downn(n, i, a[n][i] - 1);
    }
    int ans = -1;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            ans = max(ans, up[i][j] + down[i][j] - a[i][j] * 2 + 1);
            ans = max(ans, up[i][j] + lef[i][j] - a[i][j] * 2 + 1);
            ans = max(ans, up[i][j] + righ[i][j] - a[i][j] * 2 + 1);
            ans = max(ans, down[i][j] + lef[i][j] - a[i][j] * 2 + 1);
            ans = max(ans, down[i][j] + righ[i][j] - a[i][j] * 2 + 1);
            ans = max(ans, lef[i][j] + righ[i][j] - a[i][j] * 2 + 1);
        }
    }
    cout << ans;
}

Compilation message

maxcomp.cpp:59:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   59 | main() {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -