Submission #936200

# Submission time Handle Problem Language Result Execution time Memory
936200 2024-03-01T11:35:20 Z guagua0407 Bomb (IZhO17_bomb) C++17
52 / 100
154 ms 62476 KB
#include <bits/stdc++.h>
using namespace std;
 
const int mxN=2500;
int n, m, mxw=mxN, mxh=mxN, u[mxN][mxN], d[mxN][mxN], a[mxN], ans;
string g[mxN];
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
 
	cin >> n >> m;
	for(int i=0; i<n; ++i) {
		cin >> g[i];
		for(int j=0, w=0; j<m; ++j) {
			w=g[i][j]&1?w+1:0;
			if(w&&(j+1>=m||g[i][j+1]&1^1))
				mxw=min(w, mxw);
		}
	}
	for(int j=0; j<m; ++j) {
		for(int i=0, h=0; i<n; ++i) {
			h=g[i][j]&1?h+1:0;
			if(h&&(i+1>=n||g[i+1][j]&1^1))
				mxh=min(h, mxh);
			u[i][j]=i&&g[i-1][j]&1?u[i-1][j]:i;
		}
		for(int i=n-1; ~i; --i)
			d[i][j]=i<n-1&&g[i+1][j]&1?d[i+1][j]:i;
	}
	for(int i=0; i<mxw; ++i)
		a[i]=mxh;
	auto c=[]() {
		for(int i=0; i<n; ++i) {
			for(int j=0; j<m; ++j) {
				if(j&&g[i][j-1]&1||g[i][j]&1^1)
					continue;
				for(int k=0, l=0, r=n; k<mxw; ++k) {
					l=max(u[i][j+k], l);
					r=min(d[i][j+k], r);
					a[k]=min(r-l+1, a[k]);
				}
			}
		}
	};
	c();
	for(int i=0; i<n; ++i) {
		reverse(g[i].begin(), g[i].end());
		reverse(u[i], u[i]+m);
		reverse(d[i], d[i]+m);
	}
	//c();
	for(int i=0; i<mxw; ++i)
		ans=max((i+1)*a[i], ans);
	cout << ans;
}

Compilation message

bomb.cpp: In function 'int main()':
bomb.cpp:17:28: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   17 |    if(w&&(j+1>=m||g[i][j+1]&1^1))
bomb.cpp:24:28: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   24 |    if(h&&(i+1>=n||g[i+1][j]&1^1))
bomb.cpp: In lambda function:
bomb.cpp:36:31: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   36 |     if(j&&g[i][j-1]&1||g[i][j]&1^1)
bomb.cpp:36:9: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   36 |     if(j&&g[i][j-1]&1||g[i][j]&1^1)
      |        ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 11 ms 48208 KB Output is correct
4 Correct 6 ms 48220 KB Output is correct
5 Correct 1 ms 2588 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Incorrect 1 ms 4444 KB Output isn't correct
9 Incorrect 1 ms 4444 KB Output isn't correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Incorrect 1 ms 4444 KB Output isn't correct
13 Correct 1 ms 4440 KB Output is correct
14 Correct 1 ms 4528 KB Output is correct
15 Incorrect 1 ms 4444 KB Output isn't correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 6492 KB Output is correct
18 Correct 1 ms 6492 KB Output is correct
19 Incorrect 1 ms 6744 KB Output isn't correct
20 Incorrect 1 ms 6748 KB Output isn't correct
21 Correct 1 ms 6748 KB Output is correct
22 Correct 1 ms 6748 KB Output is correct
23 Incorrect 1 ms 6748 KB Output isn't correct
24 Incorrect 1 ms 6748 KB Output isn't correct
25 Incorrect 1 ms 6748 KB Output isn't correct
26 Correct 2 ms 6748 KB Output is correct
27 Correct 3 ms 10844 KB Output is correct
28 Incorrect 2 ms 10908 KB Output isn't correct
29 Incorrect 3 ms 11276 KB Output isn't correct
30 Incorrect 4 ms 13232 KB Output isn't correct
31 Correct 3 ms 11100 KB Output is correct
32 Incorrect 3 ms 11096 KB Output isn't correct
33 Incorrect 4 ms 15192 KB Output isn't correct
34 Incorrect 2 ms 10844 KB Output isn't correct
35 Incorrect 3 ms 15192 KB Output isn't correct
36 Correct 4 ms 15196 KB Output is correct
37 Incorrect 1 ms 4444 KB Output isn't correct
38 Correct 132 ms 62072 KB Output is correct
39 Incorrect 1 ms 4444 KB Output isn't correct
40 Correct 12 ms 24736 KB Output is correct
41 Correct 1 ms 4444 KB Output is correct
42 Correct 1 ms 6748 KB Output is correct
43 Correct 129 ms 62196 KB Output is correct
44 Correct 4 ms 15196 KB Output is correct
45 Incorrect 108 ms 62120 KB Output isn't correct
46 Correct 123 ms 62032 KB Output is correct
47 Incorrect 150 ms 61952 KB Output isn't correct
48 Correct 122 ms 62204 KB Output is correct
49 Correct 112 ms 62476 KB Output is correct
50 Correct 130 ms 62064 KB Output is correct
51 Correct 132 ms 62052 KB Output is correct
52 Correct 120 ms 62036 KB Output is correct
53 Correct 145 ms 62196 KB Output is correct
54 Correct 125 ms 62036 KB Output is correct
55 Incorrect 132 ms 62068 KB Output isn't correct
56 Correct 154 ms 62048 KB Output is correct
57 Incorrect 131 ms 62036 KB Output isn't correct
58 Correct 131 ms 62036 KB Output is correct
59 Correct 153 ms 62296 KB Output is correct
60 Correct 138 ms 62208 KB Output is correct
61 Correct 140 ms 62196 KB Output is correct
62 Correct 142 ms 62196 KB Output is correct
63 Correct 139 ms 62160 KB Output is correct
64 Correct 138 ms 62160 KB Output is correct
65 Correct 130 ms 62128 KB Output is correct
66 Correct 136 ms 62160 KB Output is correct
67 Correct 134 ms 62032 KB Output is correct
68 Correct 135 ms 62168 KB Output is correct
69 Correct 133 ms 62048 KB Output is correct
70 Incorrect 63 ms 51824 KB Output isn't correct
71 Incorrect 129 ms 62032 KB Output isn't correct
72 Incorrect 131 ms 62040 KB Output isn't correct
73 Correct 142 ms 62476 KB Output is correct
74 Incorrect 133 ms 62036 KB Output isn't correct
75 Incorrect 129 ms 62012 KB Output isn't correct
76 Incorrect 131 ms 62204 KB Output isn't correct
77 Incorrect 136 ms 62132 KB Output isn't correct
78 Incorrect 138 ms 62224 KB Output isn't correct
79 Incorrect 123 ms 62032 KB Output isn't correct
80 Incorrect 118 ms 62064 KB Output isn't correct
81 Incorrect 135 ms 62032 KB Output isn't correct
82 Incorrect 127 ms 62060 KB Output isn't correct
83 Incorrect 133 ms 62052 KB Output isn't correct
84 Incorrect 110 ms 62032 KB Output isn't correct
85 Incorrect 134 ms 62192 KB Output isn't correct
86 Incorrect 136 ms 62160 KB Output isn't correct
87 Incorrect 136 ms 62080 KB Output isn't correct
88 Correct 116 ms 62032 KB Output is correct
89 Correct 131 ms 62392 KB Output is correct
90 Incorrect 68 ms 51796 KB Output isn't correct
91 Incorrect 127 ms 62036 KB Output isn't correct
92 Incorrect 137 ms 62000 KB Output isn't correct
93 Incorrect 118 ms 62292 KB Output isn't correct
94 Correct 126 ms 62052 KB Output is correct
95 Incorrect 124 ms 62196 KB Output isn't correct
96 Correct 131 ms 62028 KB Output is correct
97 Incorrect 122 ms 62188 KB Output isn't correct
98 Incorrect 112 ms 62036 KB Output isn't correct
99 Incorrect 104 ms 62192 KB Output isn't correct
100 Incorrect 113 ms 62196 KB Output isn't correct