답안 #936263

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
936263 2024-03-01T13:46:28 Z guagua0407 Bomb (IZhO17_bomb) C++17
90 / 100
191 ms 60056 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]=1e9;
	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)
      |        ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 9 ms 37564 KB Output is correct
4 Correct 7 ms 36188 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Incorrect 1 ms 2396 KB Output isn't correct
8 Correct 1 ms 4452 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4644 KB Output is correct
11 Correct 1 ms 4440 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4440 KB Output is correct
17 Correct 1 ms 6748 KB Output is correct
18 Correct 1 ms 6744 KB Output is correct
19 Correct 1 ms 6744 KB Output is correct
20 Correct 1 ms 6748 KB Output is correct
21 Correct 1 ms 6684 KB Output is correct
22 Correct 1 ms 6748 KB Output is correct
23 Correct 1 ms 6720 KB Output is correct
24 Correct 1 ms 6748 KB Output is correct
25 Correct 2 ms 6748 KB Output is correct
26 Incorrect 1 ms 6744 KB Output isn't correct
27 Incorrect 2 ms 10844 KB Output isn't correct
28 Correct 3 ms 10844 KB Output is correct
29 Correct 4 ms 10908 KB Output is correct
30 Correct 4 ms 13148 KB Output is correct
31 Correct 3 ms 11160 KB Output is correct
32 Correct 3 ms 11100 KB Output is correct
33 Correct 4 ms 15196 KB Output is correct
34 Correct 3 ms 10844 KB Output is correct
35 Correct 4 ms 15196 KB Output is correct
36 Incorrect 4 ms 15196 KB Output isn't correct
37 Correct 1 ms 4444 KB Output is correct
38 Correct 167 ms 59924 KB Output is correct
39 Correct 1 ms 4444 KB Output is correct
40 Correct 15 ms 24500 KB Output is correct
41 Correct 1 ms 4444 KB Output is correct
42 Correct 2 ms 6748 KB Output is correct
43 Correct 162 ms 59728 KB Output is correct
44 Correct 4 ms 15196 KB Output is correct
45 Correct 153 ms 59732 KB Output is correct
46 Correct 180 ms 59676 KB Output is correct
47 Correct 152 ms 59808 KB Output is correct
48 Correct 138 ms 59924 KB Output is correct
49 Incorrect 149 ms 59900 KB Output isn't correct
50 Correct 149 ms 59844 KB Output is correct
51 Correct 151 ms 59884 KB Output is correct
52 Correct 159 ms 59928 KB Output is correct
53 Correct 174 ms 59928 KB Output is correct
54 Correct 159 ms 59928 KB Output is correct
55 Correct 154 ms 59872 KB Output is correct
56 Correct 170 ms 59728 KB Output is correct
57 Correct 147 ms 59792 KB Output is correct
58 Correct 152 ms 59928 KB Output is correct
59 Correct 161 ms 59676 KB Output is correct
60 Incorrect 152 ms 59928 KB Output isn't correct
61 Incorrect 155 ms 60056 KB Output isn't correct
62 Incorrect 148 ms 59928 KB Output isn't correct
63 Incorrect 155 ms 59936 KB Output isn't correct
64 Incorrect 131 ms 59932 KB Output isn't correct
65 Correct 131 ms 59732 KB Output is correct
66 Correct 181 ms 59932 KB Output is correct
67 Correct 157 ms 59812 KB Output is correct
68 Correct 143 ms 59984 KB Output is correct
69 Correct 144 ms 59924 KB Output is correct
70 Correct 90 ms 50700 KB Output is correct
71 Correct 167 ms 59924 KB Output is correct
72 Correct 179 ms 59768 KB Output is correct
73 Correct 173 ms 59924 KB Output is correct
74 Correct 171 ms 59928 KB Output is correct
75 Correct 145 ms 59924 KB Output is correct
76 Correct 165 ms 59924 KB Output is correct
77 Correct 150 ms 59728 KB Output is correct
78 Correct 144 ms 59852 KB Output is correct
79 Correct 131 ms 59732 KB Output is correct
80 Correct 167 ms 59768 KB Output is correct
81 Correct 145 ms 59800 KB Output is correct
82 Correct 181 ms 59728 KB Output is correct
83 Correct 160 ms 59716 KB Output is correct
84 Correct 151 ms 59736 KB Output is correct
85 Correct 166 ms 59848 KB Output is correct
86 Correct 164 ms 59808 KB Output is correct
87 Correct 149 ms 59932 KB Output is correct
88 Correct 182 ms 59888 KB Output is correct
89 Correct 168 ms 59928 KB Output is correct
90 Correct 87 ms 50732 KB Output is correct
91 Correct 164 ms 59848 KB Output is correct
92 Correct 170 ms 59752 KB Output is correct
93 Correct 159 ms 59472 KB Output is correct
94 Correct 175 ms 59668 KB Output is correct
95 Correct 191 ms 59664 KB Output is correct
96 Correct 162 ms 59464 KB Output is correct
97 Correct 169 ms 59472 KB Output is correct
98 Correct 172 ms 59668 KB Output is correct
99 Correct 144 ms 59472 KB Output is correct
100 Correct 147 ms 59676 KB Output is correct