Submission #496911

#TimeUsernameProblemLanguageResultExecution timeMemory
496911NalrimetMaxcomp (info1cup18_maxcomp)C++17
100 / 100
114 ms8360 KiB
#include <bits/stdc++.h> #pragma GCC optimization("g", on) #pragma GCC optimize ("inline") #pragma GCC optimization("03") #pragma GCC optimization("unroll-loops") #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #define ll long long #define pb push_back #define F first #define S second using namespace std; const int N = 1e3 + 5; const int inf = 1e9 + 7; int n, m, dist, a[N][N], cur, mx, ans = -inf, dp[N][N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for(int i = 1; i <= n; ++i){ dp[i][0] = inf; dp[i][m + 1] = inf; for(int j = 1; j <= m; ++j){ cin >> a[i][j]; dp[i][j] = a[i][j]; } } for(int j = 1; j <= m; ++j){ dp[0][j] = inf; dp[n + 1][j] = inf; } for(int i = 1; i <= n; ++i){ for(int j = 1; j <= m; ++j){ dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1); dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1); } } for(int i = 1; i <= n; ++i){ for(int j = m; j >= 1; --j){ dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1); dp[i][j] = min(dp[i][j], dp[i][j + 1] + 1); } } for(int i = n; i >= 1; --i){ for(int j = 1; j <= m; ++j){ dp[i][j] = min(dp[i][j], dp[i + 1][j] + 1); dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1); } } for(int i = n; i >= 1; --i){ for(int j = m; j >= 1; --j){ dp[i][j] = min(dp[i][j], dp[i + 1][j] + 1); dp[i][j] = min(dp[i][j], dp[i][j + 1] + 1); } } for(int i = 1; i <= n; ++i){ for(int j = 1; j <= m; ++j){ ans = max(ans, a[i][j] - dp[i][j] - 1); } } cout << ans; return 0; }

Compilation message (stderr)

maxcomp.cpp:3: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    3 | #pragma GCC optimization("g", on)
      | 
maxcomp.cpp:5: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    5 | #pragma GCC optimization("03")
      | 
maxcomp.cpp:6: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    6 | #pragma GCC optimization("unroll-loops")
      | 
maxcomp.cpp:7: warning: ignoring '#pragma comment ' [-Wunknown-pragmas]
    7 | #pragma comment(linker, "/stack:200000000")
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...