답안 #171027

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
171027 2019-12-27T05:40:09 Z super_j6 Bomb (IZhO17_bomb) C++14
43 / 100
1000 ms 50296 KB
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
using namespace std;
#define endl '\n'
#define pi pair<int, int>

const int maxn = 2502;
int n, m;
int a[maxn][maxn];

bool solve(int x, int y){
	int b[maxn][maxn];
	memset(b, 0, sizeof(b));
	for(int i = x; i <= n; i++){
		for(int j = y; j <= m; j++){
			if(a[i][j] - a[i - x][j] - a[i][j - y] + a[i - x][j - y] == x * y){
				b[i - x + 1][j - y + 1]++;
				b[i - x + 1][j + 1]--;
				b[i + 1][j - y + 1]--;
				b[i + 1][j + 1]++;
			}
		}
	}
	
	int amt = a[n][m];
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			b[i][j] += b[i - 1][j] + b[i][j - 1] - b[i - 1][j - 1];
			amt -= (b[i][j] > 0);
		}
	}
	return amt == 0;
}

int solveh(int x){
	int l = 0, r = n + 1;
	while(r - l > 1){
		int mid = (l + r) / 2;
		if(solve(mid, x)) l = mid;
		else r = mid;
	}
	return l;
}

int solvew(int x){
	int l = 0, r = m + 1;
	while(r - l > 1){
		int mid = (l + r) / 2;
		if(solve(x, mid)) l = mid;
		else r = mid;
	}
	return l;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> m;
	
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			char c;
			cin >> c;
			a[i][j] = c - '0' + a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1];
		}
	}
	
	int ret = 0;
	for(int i = 1; i <= n && solve(i, 1); i++){
		int x = solvew(i);
		i = solveh(x);
		ret = max(ret, x * i);
	}
	
	cout << ret << endl;

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 24824 KB Output is correct
2 Correct 34 ms 24952 KB Output is correct
3 Correct 70 ms 34808 KB Output is correct
4 Correct 69 ms 34936 KB Output is correct
5 Correct 55 ms 24952 KB Output is correct
6 Correct 47 ms 24828 KB Output is correct
7 Correct 42 ms 24824 KB Output is correct
8 Correct 112 ms 24956 KB Output is correct
9 Correct 125 ms 24956 KB Output is correct
10 Correct 153 ms 24824 KB Output is correct
11 Correct 107 ms 24952 KB Output is correct
12 Correct 87 ms 25080 KB Output is correct
13 Correct 42 ms 24924 KB Output is correct
14 Correct 48 ms 24824 KB Output is correct
15 Correct 91 ms 24956 KB Output is correct
16 Correct 48 ms 24952 KB Output is correct
17 Correct 58 ms 25080 KB Output is correct
18 Correct 162 ms 25208 KB Output is correct
19 Correct 117 ms 25336 KB Output is correct
20 Correct 137 ms 25296 KB Output is correct
21 Correct 128 ms 25080 KB Output is correct
22 Correct 257 ms 25312 KB Output is correct
23 Correct 113 ms 25336 KB Output is correct
24 Correct 108 ms 25272 KB Output is correct
25 Correct 136 ms 25208 KB Output is correct
26 Correct 63 ms 25336 KB Output is correct
27 Correct 94 ms 26360 KB Output is correct
28 Correct 489 ms 26600 KB Output is correct
29 Execution timed out 1054 ms 27056 KB Time limit exceeded
30 Correct 272 ms 27512 KB Output is correct
31 Correct 292 ms 27000 KB Output is correct
32 Correct 254 ms 27256 KB Output is correct
33 Correct 283 ms 27676 KB Output is correct
34 Correct 613 ms 26616 KB Output is correct
35 Correct 294 ms 27708 KB Output is correct
36 Correct 121 ms 27640 KB Output is correct
37 Correct 107 ms 24952 KB Output is correct
38 Correct 834 ms 50096 KB Output is correct
39 Correct 98 ms 24952 KB Output is correct
40 Correct 507 ms 31992 KB Output is correct
41 Correct 120 ms 24952 KB Output is correct
42 Execution timed out 1059 ms 25340 KB Time limit exceeded
43 Execution timed out 1086 ms 50012 KB Time limit exceeded
44 Execution timed out 1072 ms 27640 KB Time limit exceeded
45 Execution timed out 1081 ms 50140 KB Time limit exceeded
46 Correct 974 ms 50168 KB Output is correct
47 Execution timed out 1081 ms 50040 KB Time limit exceeded
48 Execution timed out 1070 ms 49976 KB Time limit exceeded
49 Execution timed out 1082 ms 50040 KB Time limit exceeded
50 Execution timed out 1064 ms 50080 KB Time limit exceeded
51 Execution timed out 1069 ms 50168 KB Time limit exceeded
52 Execution timed out 1074 ms 50040 KB Time limit exceeded
53 Execution timed out 1068 ms 50296 KB Time limit exceeded
54 Execution timed out 1071 ms 50040 KB Time limit exceeded
55 Execution timed out 1077 ms 50172 KB Time limit exceeded
56 Correct 904 ms 50040 KB Output is correct
57 Execution timed out 1084 ms 50040 KB Time limit exceeded
58 Execution timed out 1070 ms 50168 KB Time limit exceeded
59 Execution timed out 1076 ms 50040 KB Time limit exceeded
60 Execution timed out 1036 ms 50168 KB Time limit exceeded
61 Execution timed out 1069 ms 50060 KB Time limit exceeded
62 Execution timed out 1084 ms 50044 KB Time limit exceeded
63 Execution timed out 1028 ms 50040 KB Time limit exceeded
64 Correct 999 ms 50176 KB Output is correct
65 Execution timed out 1083 ms 50040 KB Time limit exceeded
66 Execution timed out 1073 ms 50040 KB Time limit exceeded
67 Execution timed out 1077 ms 50040 KB Time limit exceeded
68 Execution timed out 1074 ms 50044 KB Time limit exceeded
69 Execution timed out 1071 ms 50020 KB Time limit exceeded
70 Execution timed out 1079 ms 45176 KB Time limit exceeded
71 Execution timed out 1075 ms 50208 KB Time limit exceeded
72 Execution timed out 1082 ms 50012 KB Time limit exceeded
73 Execution timed out 1073 ms 50132 KB Time limit exceeded
74 Execution timed out 1063 ms 50040 KB Time limit exceeded
75 Execution timed out 1068 ms 50116 KB Time limit exceeded
76 Execution timed out 1074 ms 50040 KB Time limit exceeded
77 Execution timed out 1084 ms 50036 KB Time limit exceeded
78 Execution timed out 1073 ms 50040 KB Time limit exceeded
79 Execution timed out 1083 ms 49672 KB Time limit exceeded
80 Execution timed out 1089 ms 49656 KB Time limit exceeded
81 Execution timed out 1087 ms 49616 KB Time limit exceeded
82 Execution timed out 1076 ms 49656 KB Time limit exceeded
83 Execution timed out 1063 ms 49656 KB Time limit exceeded
84 Execution timed out 1091 ms 49656 KB Time limit exceeded
85 Execution timed out 1073 ms 49576 KB Time limit exceeded
86 Execution timed out 1079 ms 49772 KB Time limit exceeded
87 Execution timed out 1076 ms 49656 KB Time limit exceeded
88 Execution timed out 1069 ms 49720 KB Time limit exceeded
89 Execution timed out 1078 ms 49656 KB Time limit exceeded
90 Execution timed out 1074 ms 44792 KB Time limit exceeded
91 Execution timed out 1079 ms 49664 KB Time limit exceeded
92 Execution timed out 1057 ms 49784 KB Time limit exceeded
93 Execution timed out 1075 ms 49656 KB Time limit exceeded
94 Execution timed out 1084 ms 49656 KB Time limit exceeded
95 Execution timed out 1085 ms 49784 KB Time limit exceeded
96 Execution timed out 1083 ms 49656 KB Time limit exceeded
97 Execution timed out 1073 ms 49656 KB Time limit exceeded
98 Execution timed out 1087 ms 49660 KB Time limit exceeded
99 Execution timed out 1073 ms 49676 KB Time limit exceeded
100 Execution timed out 1070 ms 49684 KB Time limit exceeded