# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
936266 |
2024-03-01T13:48:50 Z |
guagua0407 |
Bomb (IZhO17_bomb) |
C++17 |
|
143 ms |
74320 KB |
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
void setIO(string s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
const int mxn=2505;
const int inf=1e9;
int c[mxn][mxn];
int up[mxn][mxn];
int down[mxn][mxn];
int n,m;
int ans[mxn];
void sir(){
for(int i=1;i<=n;i++){
for(int l=1;l<=m;l++){
if(!c[i][l]) continue;
int r=l;
while(r<=m and c[i][r]) r++;
int a=inf,b=inf;
for(int x=l;x<r;x++){
a=min(a,up[i][x]);
b=min(b,down[i][x]);
ans[x-l+1]=min(ans[x-l+1],a+b-1);
}
//cout<<i<<' '<<l<<' '<<r-1<<' '<<a<<' '<<b<<'\n';
l=r-1;
}
}
}
int main() {_
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
char cur;
cin>>cur;
c[i][j]=(cur=='1');
//cout<<c[i][j];
}
//cout<<'\n';
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(c[i][j]) up[i][j]=up[i-1][j]+1;
}
}
for(int i=n;i>=1;i--){
for(int j=1;j<=m;j++){
if(c[i][j]) down[i][j]=down[i+1][j]+1;
}
}
int mn=inf;
for(int j=1;j<=m;j++){
for(int l=1;l<=n;l++){
if(!c[l][j]) continue;
int r=l;
while(r<=n and c[r][j]) r++;
mn=min(mn,r-l);
l=r-1;
}
}
for(int i=1;i<=m;i++){
ans[i]=mn;
}
sir();
for(int i=1;i<=n;i++){
reverse(c[i]+1,c[i]+m+1);
reverse(up[i]+1,up[i]+m+1);
reverse(down[i]+1,down[i]+m+1);
}
sir();
mn=inf;
for(int i=1;i<=n;i++){
for(int l=1;l<=m;l++){
if(!c[i][l]) continue;
int r=l;
while(r<=m and c[i][r]) r++;
mn=min(mn,r-l);
l=r-1;
}
}
int mx=0;
for(int i=1;i<=mn;i++){
mx=max(mx,i*ans[i]);
}
cout<<mx<<'\n';
return 0;
}
//maybe its multiset not set
//yeeorz
//laborz
Compilation message
bomb.cpp: In function 'void setIO(std::string)':
bomb.cpp:15:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
15 | freopen((s + ".in").c_str(), "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bomb.cpp:16:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
16 | freopen((s + ".out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
13 ms |
71772 KB |
Output is correct |
4 |
Correct |
9 ms |
70492 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2652 KB |
Output is correct |
9 |
Correct |
1 ms |
2648 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2652 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
0 ms |
2396 KB |
Output is correct |
14 |
Correct |
0 ms |
2652 KB |
Output is correct |
15 |
Correct |
1 ms |
2652 KB |
Output is correct |
16 |
Correct |
1 ms |
2652 KB |
Output is correct |
17 |
Correct |
1 ms |
7004 KB |
Output is correct |
18 |
Correct |
1 ms |
7008 KB |
Output is correct |
19 |
Correct |
1 ms |
7000 KB |
Output is correct |
20 |
Correct |
1 ms |
7000 KB |
Output is correct |
21 |
Correct |
1 ms |
4956 KB |
Output is correct |
22 |
Correct |
1 ms |
7004 KB |
Output is correct |
23 |
Correct |
1 ms |
7004 KB |
Output is correct |
24 |
Correct |
1 ms |
7004 KB |
Output is correct |
25 |
Correct |
1 ms |
7004 KB |
Output is correct |
26 |
Correct |
1 ms |
7004 KB |
Output is correct |
27 |
Correct |
4 ms |
13144 KB |
Output is correct |
28 |
Correct |
4 ms |
10588 KB |
Output is correct |
29 |
Correct |
6 ms |
13656 KB |
Output is correct |
30 |
Correct |
5 ms |
14172 KB |
Output is correct |
31 |
Correct |
4 ms |
11100 KB |
Output is correct |
32 |
Correct |
4 ms |
13916 KB |
Output is correct |
33 |
Correct |
5 ms |
16220 KB |
Output is correct |
34 |
Correct |
3 ms |
11100 KB |
Output is correct |
35 |
Correct |
6 ms |
14668 KB |
Output is correct |
36 |
Correct |
6 ms |
19036 KB |
Output is correct |
37 |
Correct |
1 ms |
2652 KB |
Output is correct |
38 |
Correct |
129 ms |
73948 KB |
Output is correct |
39 |
Correct |
1 ms |
2652 KB |
Output is correct |
40 |
Correct |
18 ms |
31468 KB |
Output is correct |
41 |
Correct |
1 ms |
2652 KB |
Output is correct |
42 |
Correct |
1 ms |
7004 KB |
Output is correct |
43 |
Correct |
143 ms |
73808 KB |
Output is correct |
44 |
Correct |
6 ms |
19036 KB |
Output is correct |
45 |
Correct |
134 ms |
73964 KB |
Output is correct |
46 |
Correct |
130 ms |
73960 KB |
Output is correct |
47 |
Correct |
129 ms |
73812 KB |
Output is correct |
48 |
Correct |
123 ms |
73976 KB |
Output is correct |
49 |
Correct |
127 ms |
73808 KB |
Output is correct |
50 |
Correct |
124 ms |
74028 KB |
Output is correct |
51 |
Correct |
138 ms |
74216 KB |
Output is correct |
52 |
Correct |
123 ms |
73800 KB |
Output is correct |
53 |
Correct |
124 ms |
73812 KB |
Output is correct |
54 |
Correct |
134 ms |
74032 KB |
Output is correct |
55 |
Correct |
118 ms |
74032 KB |
Output is correct |
56 |
Correct |
128 ms |
73812 KB |
Output is correct |
57 |
Correct |
131 ms |
73956 KB |
Output is correct |
58 |
Correct |
123 ms |
73808 KB |
Output is correct |
59 |
Correct |
122 ms |
73812 KB |
Output is correct |
60 |
Correct |
122 ms |
73808 KB |
Output is correct |
61 |
Correct |
134 ms |
73844 KB |
Output is correct |
62 |
Correct |
134 ms |
73948 KB |
Output is correct |
63 |
Correct |
131 ms |
73812 KB |
Output is correct |
64 |
Correct |
129 ms |
73812 KB |
Output is correct |
65 |
Correct |
134 ms |
73936 KB |
Output is correct |
66 |
Correct |
128 ms |
74064 KB |
Output is correct |
67 |
Correct |
131 ms |
74028 KB |
Output is correct |
68 |
Correct |
131 ms |
73808 KB |
Output is correct |
69 |
Correct |
130 ms |
74068 KB |
Output is correct |
70 |
Correct |
93 ms |
62080 KB |
Output is correct |
71 |
Correct |
121 ms |
73808 KB |
Output is correct |
72 |
Correct |
136 ms |
73932 KB |
Output is correct |
73 |
Correct |
126 ms |
73812 KB |
Output is correct |
74 |
Correct |
123 ms |
73812 KB |
Output is correct |
75 |
Correct |
124 ms |
73960 KB |
Output is correct |
76 |
Correct |
125 ms |
73808 KB |
Output is correct |
77 |
Correct |
123 ms |
73964 KB |
Output is correct |
78 |
Correct |
120 ms |
73808 KB |
Output is correct |
79 |
Correct |
122 ms |
74320 KB |
Output is correct |
80 |
Correct |
122 ms |
73972 KB |
Output is correct |
81 |
Correct |
120 ms |
73812 KB |
Output is correct |
82 |
Correct |
119 ms |
73812 KB |
Output is correct |
83 |
Correct |
119 ms |
73812 KB |
Output is correct |
84 |
Correct |
136 ms |
73960 KB |
Output is correct |
85 |
Correct |
122 ms |
73960 KB |
Output is correct |
86 |
Correct |
141 ms |
74032 KB |
Output is correct |
87 |
Correct |
124 ms |
73940 KB |
Output is correct |
88 |
Correct |
124 ms |
74032 KB |
Output is correct |
89 |
Correct |
122 ms |
73968 KB |
Output is correct |
90 |
Correct |
81 ms |
63196 KB |
Output is correct |
91 |
Correct |
125 ms |
73964 KB |
Output is correct |
92 |
Correct |
124 ms |
73808 KB |
Output is correct |
93 |
Correct |
129 ms |
73812 KB |
Output is correct |
94 |
Correct |
127 ms |
73812 KB |
Output is correct |
95 |
Correct |
121 ms |
73964 KB |
Output is correct |
96 |
Correct |
127 ms |
74068 KB |
Output is correct |
97 |
Correct |
129 ms |
74032 KB |
Output is correct |
98 |
Correct |
120 ms |
73808 KB |
Output is correct |
99 |
Correct |
131 ms |
73984 KB |
Output is correct |
100 |
Correct |
127 ms |
74164 KB |
Output is correct |