# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1011008 |
2024-06-29T16:53:14 Z |
LucaIlie |
Bomb (IZhO17_bomb) |
C++17 |
|
1000 ms |
80212 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);
}
int maxArea = 0;
for ( int w = 1; w <= m; w++ ) {
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 |
13 ms |
30528 KB |
Output is correct |
4 |
Correct |
10 ms |
30432 KB |
Output is correct |
5 |
Correct |
128 ms |
496 KB |
Output is correct |
6 |
Correct |
19 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
600 KB |
Output is correct |
10 |
Correct |
0 ms |
612 KB |
Output is correct |
11 |
Correct |
1 ms |
704 KB |
Output is correct |
12 |
Correct |
0 ms |
608 KB |
Output is correct |
13 |
Correct |
0 ms |
604 KB |
Output is correct |
14 |
Correct |
1 ms |
604 KB |
Output is correct |
15 |
Correct |
1 ms |
600 KB |
Output is correct |
16 |
Correct |
0 ms |
604 KB |
Output is correct |
17 |
Correct |
4 ms |
1116 KB |
Output is correct |
18 |
Correct |
4 ms |
1372 KB |
Output is correct |
19 |
Correct |
6 ms |
1688 KB |
Output is correct |
20 |
Correct |
7 ms |
1664 KB |
Output is correct |
21 |
Correct |
5 ms |
1112 KB |
Output is correct |
22 |
Correct |
7 ms |
1372 KB |
Output is correct |
23 |
Correct |
11 ms |
1796 KB |
Output is correct |
24 |
Correct |
6 ms |
1512 KB |
Output is correct |
25 |
Correct |
11 ms |
1632 KB |
Output is correct |
26 |
Correct |
13 ms |
1792 KB |
Output is correct |
27 |
Correct |
258 ms |
5004 KB |
Output is correct |
28 |
Correct |
401 ms |
5208 KB |
Output is correct |
29 |
Correct |
431 ms |
6488 KB |
Output is correct |
30 |
Correct |
781 ms |
8280 KB |
Output is correct |
31 |
Correct |
648 ms |
6236 KB |
Output is correct |
32 |
Correct |
618 ms |
7324 KB |
Output is correct |
33 |
Correct |
890 ms |
8444 KB |
Output is correct |
34 |
Correct |
210 ms |
5972 KB |
Output is correct |
35 |
Correct |
906 ms |
8284 KB |
Output is correct |
36 |
Correct |
998 ms |
8284 KB |
Output is correct |
37 |
Correct |
0 ms |
604 KB |
Output is correct |
38 |
Execution timed out |
1092 ms |
79796 KB |
Time limit exceeded |
39 |
Correct |
1 ms |
600 KB |
Output is correct |
40 |
Execution timed out |
1052 ms |
20556 KB |
Time limit exceeded |
41 |
Correct |
1 ms |
600 KB |
Output is correct |
42 |
Correct |
13 ms |
1796 KB |
Output is correct |
43 |
Execution timed out |
1057 ms |
79956 KB |
Time limit exceeded |
44 |
Correct |
971 ms |
8436 KB |
Output is correct |
45 |
Execution timed out |
1055 ms |
79756 KB |
Time limit exceeded |
46 |
Execution timed out |
1061 ms |
79952 KB |
Time limit exceeded |
47 |
Execution timed out |
1010 ms |
79952 KB |
Time limit exceeded |
48 |
Execution timed out |
1101 ms |
79952 KB |
Time limit exceeded |
49 |
Execution timed out |
1062 ms |
79956 KB |
Time limit exceeded |
50 |
Execution timed out |
1037 ms |
79952 KB |
Time limit exceeded |
51 |
Execution timed out |
1028 ms |
79960 KB |
Time limit exceeded |
52 |
Execution timed out |
1105 ms |
79952 KB |
Time limit exceeded |
53 |
Execution timed out |
1066 ms |
79868 KB |
Time limit exceeded |
54 |
Execution timed out |
1052 ms |
79916 KB |
Time limit exceeded |
55 |
Execution timed out |
1053 ms |
79956 KB |
Time limit exceeded |
56 |
Execution timed out |
1054 ms |
79892 KB |
Time limit exceeded |
57 |
Execution timed out |
1048 ms |
80212 KB |
Time limit exceeded |
58 |
Execution timed out |
1054 ms |
79956 KB |
Time limit exceeded |
59 |
Execution timed out |
1050 ms |
80020 KB |
Time limit exceeded |
60 |
Execution timed out |
1088 ms |
79832 KB |
Time limit exceeded |
61 |
Execution timed out |
1018 ms |
79908 KB |
Time limit exceeded |
62 |
Execution timed out |
1064 ms |
79972 KB |
Time limit exceeded |
63 |
Execution timed out |
1074 ms |
79808 KB |
Time limit exceeded |
64 |
Execution timed out |
1070 ms |
79956 KB |
Time limit exceeded |
65 |
Execution timed out |
1037 ms |
79952 KB |
Time limit exceeded |
66 |
Execution timed out |
1074 ms |
79956 KB |
Time limit exceeded |
67 |
Execution timed out |
1024 ms |
79952 KB |
Time limit exceeded |
68 |
Execution timed out |
1044 ms |
80076 KB |
Time limit exceeded |
69 |
Execution timed out |
1046 ms |
79832 KB |
Time limit exceeded |
70 |
Execution timed out |
1036 ms |
63096 KB |
Time limit exceeded |
71 |
Execution timed out |
1062 ms |
79952 KB |
Time limit exceeded |
72 |
Execution timed out |
1042 ms |
79800 KB |
Time limit exceeded |
73 |
Execution timed out |
1040 ms |
79792 KB |
Time limit exceeded |
74 |
Execution timed out |
1100 ms |
79952 KB |
Time limit exceeded |
75 |
Execution timed out |
1022 ms |
79992 KB |
Time limit exceeded |
76 |
Execution timed out |
1022 ms |
79956 KB |
Time limit exceeded |
77 |
Execution timed out |
1018 ms |
79952 KB |
Time limit exceeded |
78 |
Execution timed out |
1044 ms |
80048 KB |
Time limit exceeded |
79 |
Execution timed out |
1022 ms |
79956 KB |
Time limit exceeded |
80 |
Execution timed out |
1065 ms |
79956 KB |
Time limit exceeded |
81 |
Execution timed out |
1074 ms |
79956 KB |
Time limit exceeded |
82 |
Execution timed out |
1054 ms |
79972 KB |
Time limit exceeded |
83 |
Execution timed out |
1067 ms |
79960 KB |
Time limit exceeded |
84 |
Execution timed out |
1055 ms |
79956 KB |
Time limit exceeded |
85 |
Execution timed out |
1073 ms |
79988 KB |
Time limit exceeded |
86 |
Execution timed out |
1056 ms |
79956 KB |
Time limit exceeded |
87 |
Execution timed out |
1034 ms |
79952 KB |
Time limit exceeded |
88 |
Execution timed out |
1066 ms |
79960 KB |
Time limit exceeded |
89 |
Execution timed out |
1071 ms |
79836 KB |
Time limit exceeded |
90 |
Execution timed out |
1071 ms |
63124 KB |
Time limit exceeded |
91 |
Execution timed out |
1038 ms |
79952 KB |
Time limit exceeded |
92 |
Execution timed out |
1058 ms |
79956 KB |
Time limit exceeded |
93 |
Execution timed out |
1065 ms |
79960 KB |
Time limit exceeded |
94 |
Execution timed out |
1074 ms |
79956 KB |
Time limit exceeded |
95 |
Execution timed out |
1077 ms |
79960 KB |
Time limit exceeded |
96 |
Execution timed out |
1046 ms |
79952 KB |
Time limit exceeded |
97 |
Execution timed out |
1031 ms |
79952 KB |
Time limit exceeded |
98 |
Execution timed out |
1080 ms |
79956 KB |
Time limit exceeded |
99 |
Execution timed out |
1071 ms |
79956 KB |
Time limit exceeded |
100 |
Execution timed out |
1049 ms |
79804 KB |
Time limit exceeded |