# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1011012 |
2024-06-29T16:58:58 Z |
LucaIlie |
Bomb (IZhO17_bomb) |
C++17 |
|
1000 ms |
80008 KB |
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2500;
int mat[MAX_N + 2][MAX_N + 2], up[MAX_N + 2][MAX_N + 2], down[MAX_N + 2][MAX_N + 2], hup[MAX_N + 2], hdown[MAX_N + 2], maxHeight[MAX_N + 2];
int main() {
int n, m;
cin >> n >> m;
for ( int l = 1; l <= n; l++ ) {
for ( int c = 1; c <= m; c++ ) {
char ch;
cin >> ch;
mat[l][c] = ch - '0';
}
}
for ( int l = 1; l <= n; l++ ) {
for ( int c = 1; c <= m; c++ )
up[l][c] = (mat[l][c] ? up[l - 1][c] + 1 : 0);
}
for ( int l = n; l >= 1; l-- ) {
for ( int c = 1; c <= m; c++ )
down[l][c] = (mat[l][c] ? down[l + 1][c] + 1 : 0);
}
vector<int> withds;
for ( int i = 1; i <= 50 && i <= m; i++ )
withds.push_back( i );
for ( int i = 100; i <= m - 50; i += 100 )
withds.push_back( m );
if ( m > 50 ) {
for ( int i = m - 49; i <= m; i++ )
withds.push_back( i );
}
int maxArea = 0;
for ( int w: withds ) {
int h = n;
for ( int l = 0; l <= n; l++ ) {
//printf( "LINE %d:\n", l );
deque<int> dq;
for ( int c = 1; c <= m; c++ ) {
if ( !dq.empty() && dq.front() <= c - w )
dq.pop_front();
while ( !dq.empty() && up[l][c] <= up[l][dq.back()] )
dq.pop_back();
dq.push_back( c );
hup[c] = up[l][dq.front()];
}
while ( !dq.empty() )
dq.pop_back();
for ( int c = 1; c <= m; c++ ) {
if ( !dq.empty() && dq.front() <= c - w )
dq.pop_front();
while ( !dq.empty() && down[l + 1][c] <= down[l + 1][dq.back()] )
dq.pop_back();
dq.push_back( c );
hdown[c] = down[l + 1][dq.front()];
}
while ( !dq.empty() )
dq.pop_back();
/*for ( int c = 1; c <= m; c++ )
printf( "%d ", hup[c] );
printf( "\n" );
for ( int c = 1; c <= m; c++ )
printf( "%d ", hdown[c] );
printf( "\n" );*/
for ( int c = 1; c <= m; c++ ) {
if ( hup[c] == 0 )
hdown[c] = 0;
}
for ( int c = m; c >= 1; c-- ) {
if ( !dq.empty() && dq.front() >= c + w )
dq.pop_front();
if ( c >= w ) {
while ( !dq.empty() && hdown[c] + hup[c] >= hdown[dq.back()] + hup[dq.back()] )
dq.pop_back();
dq.push_back( c );
}
if ( !dq.empty() )
maxHeight[c] = hdown[dq.front()] + hup[dq.front()];
else
maxHeight[c] = 0;
}
for ( int c = 1; c <= m; c++ ) {
if ( mat[l][c] )
h = min( h, maxHeight[c] );
//printf( "%d ", mat[l][c] ? maxHeight[c] : 9 );
}
//printf( "\n" );
}
//printf( "\n\n\n\nBA AVEM W SI H!!!!!!!!!!! %d %d\n\n\n", w, h );
maxArea = max( maxArea, w * h );
}
cout << maxArea;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
11 ms |
30440 KB |
Output is correct |
4 |
Correct |
11 ms |
30556 KB |
Output is correct |
5 |
Correct |
7 ms |
344 KB |
Output is correct |
6 |
Correct |
3 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
600 KB |
Output is correct |
11 |
Correct |
0 ms |
604 KB |
Output is correct |
12 |
Correct |
0 ms |
600 KB |
Output is correct |
13 |
Correct |
0 ms |
600 KB |
Output is correct |
14 |
Correct |
1 ms |
600 KB |
Output is correct |
15 |
Correct |
1 ms |
604 KB |
Output is correct |
16 |
Correct |
0 ms |
700 KB |
Output is correct |
17 |
Correct |
8 ms |
1304 KB |
Output is correct |
18 |
Correct |
6 ms |
1372 KB |
Output is correct |
19 |
Correct |
9 ms |
1624 KB |
Output is correct |
20 |
Correct |
10 ms |
1628 KB |
Output is correct |
21 |
Correct |
6 ms |
1116 KB |
Output is correct |
22 |
Correct |
9 ms |
1280 KB |
Output is correct |
23 |
Correct |
12 ms |
1628 KB |
Output is correct |
24 |
Correct |
8 ms |
1512 KB |
Output is correct |
25 |
Correct |
13 ms |
1800 KB |
Output is correct |
26 |
Correct |
14 ms |
1800 KB |
Output is correct |
27 |
Correct |
120 ms |
5004 KB |
Output is correct |
28 |
Correct |
124 ms |
5208 KB |
Output is correct |
29 |
Correct |
186 ms |
6492 KB |
Output is correct |
30 |
Correct |
208 ms |
8028 KB |
Output is correct |
31 |
Correct |
155 ms |
6232 KB |
Output is correct |
32 |
Correct |
186 ms |
7256 KB |
Output is correct |
33 |
Incorrect |
239 ms |
8448 KB |
Output isn't correct |
34 |
Correct |
108 ms |
5720 KB |
Output is correct |
35 |
Incorrect |
222 ms |
8280 KB |
Output isn't correct |
36 |
Correct |
252 ms |
8444 KB |
Output is correct |
37 |
Correct |
1 ms |
600 KB |
Output is correct |
38 |
Execution timed out |
1084 ms |
79772 KB |
Time limit exceeded |
39 |
Correct |
1 ms |
604 KB |
Output is correct |
40 |
Incorrect |
924 ms |
20800 KB |
Output isn't correct |
41 |
Correct |
1 ms |
600 KB |
Output is correct |
42 |
Correct |
14 ms |
1792 KB |
Output is correct |
43 |
Execution timed out |
1079 ms |
79956 KB |
Time limit exceeded |
44 |
Incorrect |
260 ms |
8440 KB |
Output isn't correct |
45 |
Execution timed out |
1101 ms |
80004 KB |
Time limit exceeded |
46 |
Execution timed out |
1061 ms |
79808 KB |
Time limit exceeded |
47 |
Execution timed out |
1074 ms |
79928 KB |
Time limit exceeded |
48 |
Execution timed out |
1043 ms |
79860 KB |
Time limit exceeded |
49 |
Execution timed out |
1052 ms |
79956 KB |
Time limit exceeded |
50 |
Execution timed out |
1028 ms |
79948 KB |
Time limit exceeded |
51 |
Execution timed out |
1062 ms |
79956 KB |
Time limit exceeded |
52 |
Execution timed out |
1094 ms |
79960 KB |
Time limit exceeded |
53 |
Execution timed out |
1035 ms |
79852 KB |
Time limit exceeded |
54 |
Execution timed out |
1028 ms |
79980 KB |
Time limit exceeded |
55 |
Execution timed out |
1048 ms |
79952 KB |
Time limit exceeded |
56 |
Execution timed out |
1085 ms |
79952 KB |
Time limit exceeded |
57 |
Execution timed out |
1065 ms |
79824 KB |
Time limit exceeded |
58 |
Execution timed out |
1065 ms |
79956 KB |
Time limit exceeded |
59 |
Execution timed out |
1070 ms |
79800 KB |
Time limit exceeded |
60 |
Execution timed out |
1018 ms |
79956 KB |
Time limit exceeded |
61 |
Execution timed out |
1064 ms |
79952 KB |
Time limit exceeded |
62 |
Execution timed out |
1070 ms |
79956 KB |
Time limit exceeded |
63 |
Execution timed out |
1101 ms |
79952 KB |
Time limit exceeded |
64 |
Execution timed out |
1033 ms |
79952 KB |
Time limit exceeded |
65 |
Execution timed out |
1036 ms |
79952 KB |
Time limit exceeded |
66 |
Execution timed out |
1064 ms |
79956 KB |
Time limit exceeded |
67 |
Execution timed out |
1069 ms |
79924 KB |
Time limit exceeded |
68 |
Execution timed out |
1018 ms |
79800 KB |
Time limit exceeded |
69 |
Execution timed out |
1066 ms |
79956 KB |
Time limit exceeded |
70 |
Execution timed out |
1032 ms |
63048 KB |
Time limit exceeded |
71 |
Execution timed out |
1073 ms |
79960 KB |
Time limit exceeded |
72 |
Execution timed out |
1040 ms |
79956 KB |
Time limit exceeded |
73 |
Execution timed out |
1047 ms |
79772 KB |
Time limit exceeded |
74 |
Execution timed out |
1039 ms |
79952 KB |
Time limit exceeded |
75 |
Execution timed out |
1053 ms |
79832 KB |
Time limit exceeded |
76 |
Execution timed out |
1059 ms |
79844 KB |
Time limit exceeded |
77 |
Execution timed out |
1067 ms |
79912 KB |
Time limit exceeded |
78 |
Execution timed out |
1067 ms |
79964 KB |
Time limit exceeded |
79 |
Execution timed out |
1078 ms |
79912 KB |
Time limit exceeded |
80 |
Execution timed out |
1075 ms |
79876 KB |
Time limit exceeded |
81 |
Execution timed out |
1054 ms |
79804 KB |
Time limit exceeded |
82 |
Execution timed out |
1066 ms |
79956 KB |
Time limit exceeded |
83 |
Execution timed out |
1066 ms |
79956 KB |
Time limit exceeded |
84 |
Execution timed out |
1031 ms |
79952 KB |
Time limit exceeded |
85 |
Execution timed out |
1068 ms |
79996 KB |
Time limit exceeded |
86 |
Execution timed out |
1059 ms |
79952 KB |
Time limit exceeded |
87 |
Execution timed out |
1059 ms |
79792 KB |
Time limit exceeded |
88 |
Execution timed out |
1049 ms |
79888 KB |
Time limit exceeded |
89 |
Execution timed out |
1045 ms |
79756 KB |
Time limit exceeded |
90 |
Execution timed out |
1040 ms |
63052 KB |
Time limit exceeded |
91 |
Execution timed out |
1033 ms |
79952 KB |
Time limit exceeded |
92 |
Execution timed out |
1047 ms |
79952 KB |
Time limit exceeded |
93 |
Execution timed out |
1046 ms |
79812 KB |
Time limit exceeded |
94 |
Execution timed out |
1034 ms |
79956 KB |
Time limit exceeded |
95 |
Execution timed out |
1062 ms |
79964 KB |
Time limit exceeded |
96 |
Execution timed out |
1034 ms |
79956 KB |
Time limit exceeded |
97 |
Execution timed out |
1014 ms |
79952 KB |
Time limit exceeded |
98 |
Execution timed out |
1030 ms |
79840 KB |
Time limit exceeded |
99 |
Execution timed out |
1075 ms |
79840 KB |
Time limit exceeded |
100 |
Execution timed out |
1037 ms |
80008 KB |
Time limit exceeded |