Submission #464910

#TimeUsernameProblemLanguageResultExecution timeMemory
464910hhhhauraMaxcomp (info1cup18_maxcomp)C++14
100 / 100
152 ms16320 KiB
#define wiwihorz #include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma loop-opt(on) #define rep(i, a, b) for(int i = a; i <= b; i ++) #define rrep(i, a, b) for(int i = b; i >= a; i--) #define all(x) x.begin(), x.end() #define ceil(a, b) ((a + b - 1) / (b)) using namespace std; #define INF 1000000000000000000 #define int long long int #define pii pair<int, int> #define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()) #ifdef wiwihorz #define print(a...) cerr << "Line " << __LINE__ << ": ", kout("[" + string(#a) + "] = ", a) void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;} void kout() { cerr << endl; } template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...);} #else #define print(...) 0 #define vprint(...) 0 #endif namespace solver { int n, m, ans; vector<vector<int>> a, b; void init_(int _n, int _m) { n = _n, m = _m; a.assign(n + 1, vector<int>(m + 1, 0)); b.assign(n + 1, vector<int>(m + 1, INF)); } int cal() { int ans = -INF; rep(i, 1, n) { rep(j, 1, m) { b[i][j] = a[i][j] + 1; if(i > 1) b[i][j] = min(b[i][j], b[i - 1][j] + 1); if(j > 1) b[i][j] = min(b[i][j], b[i][j - 1] + 1); ans = max(ans, a[i][j] - b[i][j]); } } return ans; } void solve() { int ans = -INF; ans = max(ans, cal()); rep(i, 1, n) rep(j, 1, m) { if(j <= m / 2) swap(a[i][j], a[i][m - j + 1]); } ans = max(ans, cal()); rep(i, 1, n) rep(j, 1, m) { if(i <= n / 2) swap(a[i][j], a[n - i + 1][j]); } ans = max(ans, cal()); rep(i, 1, n) rep(j, 1, m) { if(j <= m / 2) swap(a[i][j], a[i][m - j + 1]); } ans = max(ans, cal()); cout << ans << "\n"; } }; using namespace solver; signed main() { ios::sync_with_stdio(false), cin.tie(0); int n, m; cin >> n >> m; init_(n, m); rep(i, 1, n) rep(j, 1, m) cin >> a[i][j]; solve(); return 0; }

Compilation message (stderr)

maxcomp.cpp:4: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
    4 | #pragma loop-opt(on)
      | 
maxcomp.cpp:20:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   20 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
      |             ^~~~
maxcomp.cpp:20:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   20 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
      |                     ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...