답안 #386465

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
386465 2021-04-06T15:52:01 Z vanic Bomb (IZhO17_bomb) C++14
41 / 100
1000 ms 1388 KB
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <map>
#include <cstring>
#include <array>
#include <bitset>
#include <cassert>
 
using namespace std;
 
const int maxn=2505;
 
bitset < maxn > a[maxn];
bitset < maxn > b[maxn];
int n, m;
 
bool provjeri(int x, int y){
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			b[i][j]=a[i][j];
		}
	}
	bool ne;
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			if(a[i][j]){
				ne=0;
				for(int k=i; k<i+x; k++){
					for(int l=j; l<j+y; l++){
						if(k>=n || l>=m || !a[k][l]){
							ne=1;
							break;
						}
						if(ne){
							break;
						}
					}
				}
				if(!ne){
					for(int k=i; k<i+x; k++){
						for(int l=j; l<j+y; l++){
							b[k][l]=0;
						}
					}
				}
			}
		}
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			if(b[i][j]){
				return 0;
			}
		}
	}
	return 1;
 
}
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m;
	string s;
	for(int i=0; i<n; i++){
		cin >> s;
		for(int j=0; j<m; j++){
			if(s[j]=='1'){
				a[i][j]=1;
			}
		}
	}
	int br=0;
	int mr=1e9, mc=1e9;
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			if(a[i][j]){
				br++;
			}
			else if(br){
				mr=min(mr, br);
				br=0;
			}
		}
		if(br){
			mr=min(mr, br);
			br=0;
		}
	}
	for(int j=0; j<m; j++){
		for(int i=0; i<n; i++){
			if(a[i][j]){
				br++;
			}
			else if(br){
				mc=min(mc, br);
				br=0;
			}
		}
		if(br){
			mc=min(mc, br);
			br=0;
		}
	}
	assert(mr!=1e9);
	if(n>100 || m>100){
		cout << mr*mc << '\n';
		return 0;
	}
	int maksi=0;
	for(int i=mc; i>0; i--){
		for(int j=mr; j>0; j--){
			if(provjeri(i, j)){
				maksi=max(maksi, i*j);
			}
		}
	}
	cout << maksi << '\n';
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 1132 KB Output is correct
4 Correct 1 ms 1132 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 2 ms 364 KB Output is correct
18 Correct 10 ms 364 KB Output is correct
19 Correct 36 ms 364 KB Output is correct
20 Correct 41 ms 492 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 2 ms 364 KB Output is correct
23 Correct 263 ms 456 KB Output is correct
24 Correct 43 ms 364 KB Output is correct
25 Correct 910 ms 492 KB Output is correct
26 Correct 154 ms 492 KB Output is correct
27 Correct 2 ms 492 KB Output is correct
28 Incorrect 2 ms 364 KB Output isn't correct
29 Incorrect 2 ms 492 KB Output isn't correct
30 Incorrect 2 ms 492 KB Output isn't correct
31 Incorrect 2 ms 364 KB Output isn't correct
32 Incorrect 2 ms 492 KB Output isn't correct
33 Incorrect 2 ms 492 KB Output isn't correct
34 Incorrect 2 ms 364 KB Output isn't correct
35 Incorrect 2 ms 364 KB Output isn't correct
36 Correct 2 ms 492 KB Output is correct
37 Correct 1 ms 364 KB Output is correct
38 Correct 37 ms 1132 KB Output is correct
39 Correct 2 ms 364 KB Output is correct
40 Incorrect 5 ms 620 KB Output isn't correct
41 Correct 2 ms 364 KB Output is correct
42 Execution timed out 1078 ms 364 KB Time limit exceeded
43 Correct 35 ms 1132 KB Output is correct
44 Incorrect 2 ms 492 KB Output isn't correct
45 Incorrect 34 ms 1132 KB Output isn't correct
46 Correct 35 ms 1132 KB Output is correct
47 Incorrect 34 ms 1132 KB Output isn't correct
48 Incorrect 33 ms 1132 KB Output isn't correct
49 Correct 37 ms 1132 KB Output is correct
50 Incorrect 33 ms 1132 KB Output isn't correct
51 Incorrect 35 ms 1260 KB Output isn't correct
52 Incorrect 41 ms 1132 KB Output isn't correct
53 Incorrect 38 ms 1132 KB Output isn't correct
54 Incorrect 31 ms 1132 KB Output isn't correct
55 Incorrect 37 ms 1132 KB Output isn't correct
56 Correct 37 ms 1132 KB Output is correct
57 Incorrect 31 ms 1004 KB Output isn't correct
58 Incorrect 31 ms 1132 KB Output isn't correct
59 Incorrect 31 ms 1004 KB Output isn't correct
60 Correct 33 ms 1132 KB Output is correct
61 Correct 37 ms 1132 KB Output is correct
62 Correct 37 ms 1132 KB Output is correct
63 Correct 37 ms 1260 KB Output is correct
64 Correct 30 ms 1132 KB Output is correct
65 Incorrect 38 ms 1132 KB Output isn't correct
66 Incorrect 34 ms 1132 KB Output isn't correct
67 Incorrect 34 ms 1132 KB Output isn't correct
68 Incorrect 35 ms 1132 KB Output isn't correct
69 Incorrect 31 ms 1004 KB Output isn't correct
70 Incorrect 22 ms 620 KB Output isn't correct
71 Incorrect 29 ms 876 KB Output isn't correct
72 Incorrect 31 ms 876 KB Output isn't correct
73 Incorrect 31 ms 876 KB Output isn't correct
74 Incorrect 33 ms 1132 KB Output isn't correct
75 Incorrect 31 ms 1004 KB Output isn't correct
76 Incorrect 31 ms 1004 KB Output isn't correct
77 Incorrect 32 ms 1004 KB Output isn't correct
78 Incorrect 32 ms 1004 KB Output isn't correct
79 Incorrect 37 ms 492 KB Output isn't correct
80 Incorrect 38 ms 620 KB Output isn't correct
81 Incorrect 28 ms 620 KB Output isn't correct
82 Incorrect 32 ms 1132 KB Output isn't correct
83 Incorrect 33 ms 1388 KB Output isn't correct
84 Incorrect 29 ms 364 KB Output isn't correct
85 Incorrect 31 ms 1132 KB Output isn't correct
86 Incorrect 36 ms 1132 KB Output isn't correct
87 Incorrect 32 ms 1132 KB Output isn't correct
88 Incorrect 32 ms 1004 KB Output isn't correct
89 Incorrect 32 ms 1132 KB Output isn't correct
90 Incorrect 21 ms 1004 KB Output isn't correct
91 Incorrect 31 ms 1132 KB Output isn't correct
92 Incorrect 32 ms 1132 KB Output isn't correct
93 Incorrect 36 ms 1132 KB Output isn't correct
94 Incorrect 32 ms 1132 KB Output isn't correct
95 Incorrect 32 ms 1132 KB Output isn't correct
96 Incorrect 32 ms 1132 KB Output isn't correct
97 Incorrect 36 ms 1132 KB Output isn't correct
98 Incorrect 31 ms 1132 KB Output isn't correct
99 Incorrect 33 ms 1132 KB Output isn't correct
100 Incorrect 36 ms 1132 KB Output isn't correct