Submission #386450

# Submission time Handle Problem Language Result Execution time Memory
386450 2021-04-06T15:02:25 Z vanic Bomb (IZhO17_bomb) C++14
36 / 100
1000 ms 1264 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;

}

void radi2(){
	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);
	cout << mr*mc << '\n';
}

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;
			}
		}
	}
	if(n>100 || m>100){
		radi2();
		return 0;
	}
	int maksi=0;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
			if(provjeri(i, j)){
				maksi=max(maksi, i*j);
			}
		}
	}
	cout << maksi << '\n';
	return 0;
}
# Verdict Execution time Memory 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 2 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 2 ms 364 KB Output is correct
8 Correct 3 ms 364 KB Output is correct
9 Correct 4 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 4 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 3 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 10 ms 364 KB Output is correct
17 Correct 807 ms 492 KB Output is correct
18 Correct 158 ms 364 KB Output is correct
19 Execution timed out 1078 ms 364 KB Time limit exceeded
20 Execution timed out 1077 ms 364 KB Time limit exceeded
21 Correct 134 ms 428 KB Output is correct
22 Correct 411 ms 364 KB Output is correct
23 Execution timed out 1083 ms 364 KB Time limit exceeded
24 Correct 917 ms 448 KB Output is correct
25 Execution timed out 1087 ms 364 KB Time limit exceeded
26 Execution timed out 1080 ms 364 KB Time limit exceeded
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 3 ms 364 KB Output isn't correct
32 Incorrect 2 ms 492 KB Output isn't correct
33 Incorrect 3 ms 492 KB Output isn't correct
34 Incorrect 1 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 5 ms 364 KB Output is correct
38 Correct 35 ms 1132 KB Output is correct
39 Correct 6 ms 364 KB Output is correct
40 Incorrect 6 ms 620 KB Output isn't correct
41 Correct 6 ms 364 KB Output is correct
42 Execution timed out 1095 ms 364 KB Time limit exceeded
43 Correct 41 ms 1132 KB Output is correct
44 Incorrect 3 ms 492 KB Output isn't correct
45 Incorrect 34 ms 1132 KB Output isn't correct
46 Correct 34 ms 1132 KB Output is correct
47 Incorrect 31 ms 1132 KB Output isn't correct
48 Incorrect 32 ms 1132 KB Output isn't correct
49 Correct 35 ms 1132 KB Output is correct
50 Incorrect 31 ms 1132 KB Output isn't correct
51 Incorrect 31 ms 1132 KB Output isn't correct
52 Incorrect 31 ms 1132 KB Output isn't correct
53 Incorrect 31 ms 1132 KB Output isn't correct
54 Incorrect 29 ms 1132 KB Output isn't correct
55 Incorrect 29 ms 1132 KB Output isn't correct
56 Correct 35 ms 1132 KB Output is correct
57 Incorrect 34 ms 1004 KB Output isn't correct
58 Incorrect 29 ms 1132 KB Output isn't correct
59 Incorrect 28 ms 1004 KB Output isn't correct
60 Correct 31 ms 1132 KB Output is correct
61 Correct 43 ms 1132 KB Output is correct
62 Correct 34 ms 1132 KB Output is correct
63 Correct 39 ms 1132 KB Output is correct
64 Correct 30 ms 1132 KB Output is correct
65 Incorrect 35 ms 1260 KB Output isn't correct
66 Incorrect 34 ms 1188 KB Output isn't correct
67 Incorrect 32 ms 1132 KB Output isn't correct
68 Incorrect 32 ms 1132 KB Output isn't correct
69 Incorrect 28 ms 1004 KB Output isn't correct
70 Incorrect 21 ms 620 KB Output isn't correct
71 Incorrect 29 ms 948 KB Output isn't correct
72 Incorrect 37 ms 992 KB Output isn't correct
73 Incorrect 31 ms 968 KB Output isn't correct
74 Incorrect 30 ms 1004 KB Output isn't correct
75 Incorrect 31 ms 1004 KB Output isn't correct
76 Incorrect 33 ms 1004 KB Output isn't correct
77 Incorrect 30 ms 1004 KB Output isn't correct
78 Incorrect 30 ms 1004 KB Output isn't correct
79 Incorrect 33 ms 524 KB Output isn't correct
80 Incorrect 28 ms 748 KB Output isn't correct
81 Incorrect 31 ms 620 KB Output isn't correct
82 Incorrect 30 ms 1132 KB Output isn't correct
83 Incorrect 31 ms 1132 KB Output isn't correct
84 Incorrect 26 ms 428 KB Output isn't correct
85 Incorrect 30 ms 1188 KB Output isn't correct
86 Incorrect 33 ms 1132 KB Output isn't correct
87 Incorrect 32 ms 1188 KB Output isn't correct
88 Incorrect 31 ms 1128 KB Output isn't correct
89 Incorrect 32 ms 1260 KB Output isn't correct
90 Incorrect 19 ms 1004 KB Output isn't correct
91 Incorrect 30 ms 1132 KB Output isn't correct
92 Incorrect 32 ms 1264 KB Output isn't correct
93 Incorrect 34 ms 1132 KB Output isn't correct
94 Incorrect 30 ms 1132 KB Output isn't correct
95 Incorrect 30 ms 1132 KB Output isn't correct
96 Incorrect 40 ms 1132 KB Output isn't correct
97 Incorrect 36 ms 1260 KB Output isn't correct
98 Incorrect 37 ms 1136 KB Output isn't correct
99 Incorrect 32 ms 1132 KB Output isn't correct
100 Incorrect 36 ms 1132 KB Output isn't correct