답안 #464910

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
464910 2021-08-14T12:36:21 Z hhhhaura Maxcomp (info1cup18_maxcomp) C++14
100 / 100
152 ms 16320 KB
#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

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;}
      |                     ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 268 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 268 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 146 ms 16308 KB Output is correct
19 Correct 147 ms 16320 KB Output is correct
20 Correct 140 ms 15528 KB Output is correct
21 Correct 147 ms 16300 KB Output is correct
22 Correct 152 ms 16312 KB Output is correct
23 Correct 148 ms 16240 KB Output is correct
24 Correct 143 ms 15516 KB Output is correct