Submission #168978

# Submission time Handle Problem Language Result Execution time Memory
168978 2019-12-17T10:43:08 Z abil Bomb (IZhO17_bomb) C++14
8 / 100
1000 ms 105856 KB
#include <bits/stdc++.h>

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define all(s) s.begin(),s.end()
//#define int long long

using namespace std;

const int N = (2500 + 12);
const int mod = (1e9 + 7);
const int INF = (0x3f3f3f3f);

char a[N][N];
int up[N][N], down[N][N], leftt[N][N], rightt[N][N];

int n, m;
bool solve(int x,int y){
	for(int i = 1;i <= n; i++){
		for(int j = 1;j <= m; j++){
			if(a[i][j] == '1'){
				if((up[i][j] + down[i][j] - 1 < x || leftt[i][j] + rightt[i][j] - 1 < y) && (up[i][j] + down[i][j] - 1 < y || leftt[i][j] + rightt[i][j] - 1 < x)){
					return false;
				}
			}
		}
	}
	return true;
}

main()
{
	cin >> n >> m;
	for(int i = 1;i <= n; i++){
		for(int j = 1;j <= m; j++){
			cin >> a[i][j];
		}
	}
	int mnx = INF, mny = INF;
	for(int i = 1;i <= n; i++){
		int cnt = 0;
		for(int j = 1;j <= m; j++){
			cnt = (a[i][j] == '0' ? 0 : cnt + 1);
			leftt[i][j] = cnt;
			mny = min(mny, leftt[i][j]);
		}
	}
	for(int i = 1;i <= n; i++){
		int cnt = 0;
		for(int j = m;j >= 1; j--){
			cnt = (a[i][j] == '0' ? 0 : cnt + 1);
			rightt[i][j] = cnt;
			mny = min(mny, rightt[i][j]);
		}
	}
	for(int i = 1;i <= m; i++){
		int cnt = 0;
		for(int j = 1;j <= n; j++){
			cnt = (a[j][i] == '0' ? 0 : cnt + 1);
			up[j][i] = cnt;
			mnx = min(mnx, up[j][i]);
		}
	}
	for(int i = 1;i <= m; i++){
		int cnt = 0;
		for(int j = n;j >= 1; j--){
			cnt = (a[j][i] == '0' ? 0 : cnt + 1);
			down[j][i] = cnt;
		}
	}
	int ans = 1;
	for(int i = 1;i <= n; i++){
		for(int j = 1;j <= m; j++){
			if(solve(i,j)){
				ans = max(ans, i * j);
			}
		}
	}
	cout << ans;
}
/*
6 6
000100
000100
111111
000010
000010
000010
*/

Compilation message

bomb.cpp:33:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 83 ms 46712 KB Output is correct
4 Correct 45 ms 46584 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Incorrect 2 ms 380 KB Output isn't correct
8 Incorrect 2 ms 760 KB Output isn't correct
9 Incorrect 2 ms 760 KB Output isn't correct
10 Incorrect 2 ms 632 KB Output isn't correct
11 Incorrect 2 ms 760 KB Output isn't correct
12 Incorrect 2 ms 632 KB Output isn't correct
13 Incorrect 2 ms 632 KB Output isn't correct
14 Correct 2 ms 632 KB Output is correct
15 Incorrect 2 ms 760 KB Output isn't correct
16 Incorrect 2 ms 760 KB Output isn't correct
17 Correct 4 ms 1656 KB Output is correct
18 Incorrect 4 ms 1784 KB Output isn't correct
19 Incorrect 7 ms 2172 KB Output isn't correct
20 Incorrect 7 ms 2168 KB Output isn't correct
21 Incorrect 3 ms 1400 KB Output isn't correct
22 Incorrect 4 ms 1912 KB Output isn't correct
23 Incorrect 15 ms 2296 KB Output isn't correct
24 Incorrect 6 ms 1912 KB Output isn't correct
25 Incorrect 17 ms 2296 KB Output isn't correct
26 Incorrect 22 ms 2424 KB Output isn't correct
27 Incorrect 20 ms 7032 KB Output isn't correct
28 Incorrect 25 ms 7544 KB Output isn't correct
29 Execution timed out 1067 ms 9592 KB Time limit exceeded
30 Execution timed out 1085 ms 11384 KB Time limit exceeded
31 Execution timed out 1080 ms 8952 KB Time limit exceeded
32 Execution timed out 1074 ms 10360 KB Time limit exceeded
33 Execution timed out 1071 ms 12024 KB Time limit exceeded
34 Incorrect 26 ms 8312 KB Output isn't correct
35 Incorrect 902 ms 12152 KB Output isn't correct
36 Execution timed out 1080 ms 12028 KB Time limit exceeded
37 Incorrect 2 ms 760 KB Output isn't correct
38 Execution timed out 1092 ms 105600 KB Time limit exceeded
39 Incorrect 2 ms 760 KB Output isn't correct
40 Execution timed out 1077 ms 29040 KB Time limit exceeded
41 Incorrect 2 ms 760 KB Output isn't correct
42 Incorrect 44 ms 2424 KB Output isn't correct
43 Execution timed out 1096 ms 105684 KB Time limit exceeded
44 Execution timed out 1084 ms 12024 KB Time limit exceeded
45 Execution timed out 1089 ms 105720 KB Time limit exceeded
46 Execution timed out 1085 ms 105720 KB Time limit exceeded
47 Execution timed out 1076 ms 105712 KB Time limit exceeded
48 Execution timed out 1087 ms 105664 KB Time limit exceeded
49 Execution timed out 1082 ms 105612 KB Time limit exceeded
50 Execution timed out 1072 ms 105624 KB Time limit exceeded
51 Execution timed out 1079 ms 105564 KB Time limit exceeded
52 Execution timed out 1091 ms 105512 KB Time limit exceeded
53 Execution timed out 1096 ms 105676 KB Time limit exceeded
54 Execution timed out 1086 ms 105760 KB Time limit exceeded
55 Execution timed out 1081 ms 105720 KB Time limit exceeded
56 Execution timed out 1074 ms 105720 KB Time limit exceeded
57 Execution timed out 1087 ms 105856 KB Time limit exceeded
58 Execution timed out 1065 ms 105720 KB Time limit exceeded
59 Execution timed out 1080 ms 105816 KB Time limit exceeded
60 Execution timed out 1089 ms 105736 KB Time limit exceeded
61 Execution timed out 1089 ms 105680 KB Time limit exceeded
62 Execution timed out 1088 ms 105812 KB Time limit exceeded
63 Execution timed out 1086 ms 105656 KB Time limit exceeded
64 Execution timed out 1091 ms 105720 KB Time limit exceeded
65 Execution timed out 1082 ms 105848 KB Time limit exceeded
66 Execution timed out 1083 ms 105784 KB Time limit exceeded
67 Execution timed out 1093 ms 105708 KB Time limit exceeded
68 Execution timed out 1071 ms 105588 KB Time limit exceeded
69 Execution timed out 1084 ms 105680 KB Time limit exceeded
70 Execution timed out 1062 ms 84644 KB Time limit exceeded
71 Execution timed out 1090 ms 105736 KB Time limit exceeded
72 Execution timed out 1089 ms 105592 KB Time limit exceeded
73 Execution timed out 1080 ms 105556 KB Time limit exceeded
74 Execution timed out 1083 ms 105776 KB Time limit exceeded
75 Execution timed out 1099 ms 105592 KB Time limit exceeded
76 Execution timed out 1080 ms 105712 KB Time limit exceeded
77 Execution timed out 1088 ms 105556 KB Time limit exceeded
78 Execution timed out 1080 ms 105752 KB Time limit exceeded
79 Execution timed out 1086 ms 105620 KB Time limit exceeded
80 Execution timed out 1090 ms 105616 KB Time limit exceeded
81 Execution timed out 1073 ms 105728 KB Time limit exceeded
82 Execution timed out 1097 ms 105720 KB Time limit exceeded
83 Execution timed out 1090 ms 105592 KB Time limit exceeded
84 Execution timed out 1088 ms 105660 KB Time limit exceeded
85 Execution timed out 1087 ms 105672 KB Time limit exceeded
86 Execution timed out 1092 ms 105592 KB Time limit exceeded
87 Execution timed out 1088 ms 105408 KB Time limit exceeded
88 Execution timed out 1093 ms 104912 KB Time limit exceeded
89 Execution timed out 1086 ms 104864 KB Time limit exceeded
90 Execution timed out 1086 ms 84092 KB Time limit exceeded
91 Execution timed out 1088 ms 104892 KB Time limit exceeded
92 Execution timed out 1090 ms 104924 KB Time limit exceeded
93 Execution timed out 1086 ms 104940 KB Time limit exceeded
94 Execution timed out 1087 ms 105016 KB Time limit exceeded
95 Execution timed out 1080 ms 104808 KB Time limit exceeded
96 Execution timed out 1090 ms 104812 KB Time limit exceeded
97 Execution timed out 1083 ms 104952 KB Time limit exceeded
98 Execution timed out 1083 ms 104840 KB Time limit exceeded
99 Execution timed out 1076 ms 104888 KB Time limit exceeded
100 Execution timed out 1083 ms 104904 KB Time limit exceeded