답안 #93230

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
93230 2019-01-07T10:19:46 Z Abelyan Bomb (IZhO17_bomb) C++17
15 / 100
4 ms 636 KB
#include <iostream>
#include <algorithm>
#include <climits>
#include <cassert>
using namespace std;

typedef long long ll;
typedef long double ld;

#define fr first
#define sc second
#define FOR(i, a) for (int i = 0; i < (a); i++)
#define F0R(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i,a) for (int i = (a)-1; i >= 0; i--)
#define F0Rd(i,a,b) for (int i = (b); i >= (a); i--)
#define trav(a, x) for (auto& a : x)

const int N = 2506;
char c[N][N];
int prdz[N][N], praj[N][N], ans1, ans2, pr[N];

void ad(int a, int b){
	//cout << a << " " << b << endl;
	if (a > ans2)return;
	if (b > ans1)b = ans1;
	pr[a] = min(pr[a], b);
}

int main(){
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	assert(n <= 20 && m <= 20);
	for (int i = 0; i<n; i++){
		cin >> c[i];
		pr[i] = INT_MAX;
	}
	pr[n] = INT_MAX;
	int mn = INT_MAX;
	for (int i = 0; i<n; i++){
		int tv = 0;
		for (int j = 0; j<m; j++){
			if (c[i][j] == '1'){
				if (j == 0)prdz[i][j] = 1;
				else prdz[i][j] = prdz[i][j - 1] + 1;
				tv++;
			}
			else if (tv != 0){
				mn = min(mn, tv);
				tv = 0;
			}
		}
		for (int j = m - 1; j >= 0; j--){
			if (c[i][j] == '1'){
				praj[i][j] = praj[i][j + 1] + 1;
			}
		}
		if (tv != 0)mn = min(mn, tv);
	}
	ans1 = mn;
	mn = INT_MAX;
	for (int j = 0; j<m; j++){
		int tv = 0;
		for (int i = 0; i<n; i++){
			if (c[i][j] == '1'){
				tv++;
			}
			else if (tv != 0){
				mn = min(mn, tv);
				tv = 0;
			}
		}
		if (tv != 0)mn = min(mn, tv);
	}
	ans2 = mn;
	//cout << ans1 << " " << ans2 << endl;
	for (int j = 0; j < m; j++){
		for (int i = 0; i < n; i++){
			if (c[i][j] == '1' && (j == 0 || c[i][j - 1] == '0')){
				int ans = INT_MAX, k = 0;
				while (i<n && c[i][j] == '1'){
					k++;
					ans = min(ans, praj[i][j]);
					ad(k, ans);
					i++;
				}
				i--;
			}
			else if (c[i][j] == '1' && (j == m - 1 || c[i][j + 1] == '0')){
				int ans = INT_MAX, k = 0;
				while (i<n && c[i][j] == '1'){
					k++;
					ans = min(ans, prdz[i][j]);
					ad(k, ans);
					i++;
				}
				i--;
			}
		}
	}
	for (int j = 0; j<m; j++){
		for (int i = n - 1; i >= 0; i--){
			if (c[i][j] == '1' && (j == 0 || c[i][j - 1] == '0')){
				int ans = INT_MAX, k = 0;
				while (i<n && c[i][j] == '1'){
					k++;
					ans = min(ans, praj[i][j]);
					ad(k, ans);
					i--;
				}
				i++;
			}
			else if (c[i][j] == '1' && (j == m - 1 || c[i][j + 1] == '0')){
				int ans = INT_MAX, k = 0;
				while (i<n && c[i][j] == '1'){
					k++;
					ans = min(ans, prdz[i][j]);
					ad(k, ans);
					i--;
				}
				i++;
			}
		}
	}
	int verj = 1;
	for (int i = 1; i <= n; i++){
		if (pr[i] == INT_MAX)continue;
		verj = max(verj, i*pr[i]);
	}
	cout << verj << endl;
	return 0;
}
/*
5 6
001000
111110
111110
111110
000100
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 3 ms 604 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 4 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Correct 1 ms 376 KB Output is correct
8 Correct 2 ms 504 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 504 KB Output is correct
14 Correct 2 ms 508 KB Output is correct
15 Correct 2 ms 496 KB Output is correct
16 Correct 2 ms 504 KB Output is correct
17 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 4 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 4 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
21 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
23 Runtime error 4 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
24 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Runtime error 4 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
27 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
28 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
29 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
30 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
31 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Runtime error 4 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
33 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
34 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
35 Runtime error 4 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
36 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
37 Correct 2 ms 604 KB Output is correct
38 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
39 Correct 2 ms 632 KB Output is correct
40 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
41 Correct 2 ms 632 KB Output is correct
42 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
43 Runtime error 4 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
44 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
45 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
46 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
47 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
48 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
49 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
50 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
51 Runtime error 4 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
52 Runtime error 4 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
53 Runtime error 3 ms 636 KB Execution killed with signal 11 (could be triggered by violating memory limits)
54 Runtime error 4 ms 544 KB Execution killed with signal 11 (could be triggered by violating memory limits)
55 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
56 Runtime error 4 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
57 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
58 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
59 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
60 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
61 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
62 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
63 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
64 Runtime error 3 ms 636 KB Execution killed with signal 11 (could be triggered by violating memory limits)
65 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
66 Runtime error 4 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
67 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
68 Runtime error 4 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
69 Runtime error 3 ms 552 KB Execution killed with signal 11 (could be triggered by violating memory limits)
70 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
71 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
72 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
73 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
74 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
75 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
76 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
77 Runtime error 4 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
78 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
79 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
80 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
81 Runtime error 4 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
82 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
83 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
84 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
85 Runtime error 3 ms 508 KB Execution killed with signal 11 (could be triggered by violating memory limits)
86 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
87 Runtime error 4 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
88 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
89 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
90 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
91 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
92 Runtime error 4 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
93 Runtime error 4 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
94 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
95 Runtime error 4 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
96 Runtime error 4 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
97 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
98 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
99 Runtime error 4 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
100 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)