Submission #96539

# Submission time Handle Problem Language Result Execution time Memory
96539 2019-02-10T07:11:09 Z choikiwon Bomb (IZhO17_bomb) C++17
100 / 100
514 ms 67832 KB
#include<bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
char c1[2505][2505],c2[2505][2505];
int n,m,l,r,bolo;
int lf[2505][2505],rg[2505][ 2505],zr[2505];
pair<int, int> ans;

int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;++i) scanf("%s", &c1[i][1]);
for(int i=0;i<2505;++i) zr[i] = inf;

for(int i=0;i<2;++i) {
    memset((lf), 0, sizeof(lf));
    memset((rg), 0, sizeof(rg));
for(int i=1;i<=n;++i){
  for(int j=1;j<=m;++j)
    if(c1[i][j] == '1') lf[i][j] = lf[i][j-1] + 1;
  for(int j=m;j>=1;--j)
    if(c1[i][j] == '1') rg[i][j] = rg[i][j+1] + 1;
  for(int j=1;j<=m;++j)
    if(c1[i][j] == '1' && c1[i][j+1] != '1') zr[1] = min(zr[1], lf[i][j]);
    }

    for(int j=1;j<=m;++j)
    for(int i=0;i<=n+1;++i)
        if(c1[i][j] == '1') {
        l = min(l, lf[i][j]);  r = min(r, rg[i][j]);
        zr[i - bolo] = min(zr[i - bolo], l + r - 1);
        } else {
        if(i && bolo != i-1) zr[i - bolo] = 0;
        l = inf; r = inf;  bolo = i;
        }
 for(int i=1;i<=n;++i)
        for(int j=1;j<=m;++j)
            c2[i][j] = c1[n+1-i][j];
 for(int i=1;i<=n;++i)
        for(int j=1;j<=m;++j)
             c1[i][j] = c2[i][j];
}
int b = inf;

for(int a=1;a<=2504;++a) {
  b = min(b, zr[a]);
  ans = max(ans, {a*b, b});
}

cout << ans.first<< endl;
}

Compilation message

bomb.cpp: In function 'int main()':
bomb.cpp:10:6: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf("%d%d",&n,&m);
 ~~~~~^~~~~~~~~~~~~~
bomb.cpp:11:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 for(int i=1;i<=n;++i) scanf("%s", &c1[i][1]);
                       ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 51 ms 49528 KB Output is correct
2 Correct 52 ms 49632 KB Output is correct
3 Correct 61 ms 61816 KB Output is correct
4 Correct 62 ms 61688 KB Output is correct
5 Correct 51 ms 49528 KB Output is correct
6 Correct 52 ms 49528 KB Output is correct
7 Correct 51 ms 49528 KB Output is correct
8 Correct 52 ms 49508 KB Output is correct
9 Correct 53 ms 49528 KB Output is correct
10 Correct 53 ms 49548 KB Output is correct
11 Correct 53 ms 49528 KB Output is correct
12 Correct 45 ms 49528 KB Output is correct
13 Correct 51 ms 49528 KB Output is correct
14 Correct 53 ms 49528 KB Output is correct
15 Correct 49 ms 49472 KB Output is correct
16 Correct 46 ms 49528 KB Output is correct
17 Correct 52 ms 49804 KB Output is correct
18 Correct 52 ms 49784 KB Output is correct
19 Correct 53 ms 49884 KB Output is correct
20 Correct 52 ms 49912 KB Output is correct
21 Correct 51 ms 49656 KB Output is correct
22 Correct 51 ms 49848 KB Output is correct
23 Correct 51 ms 49912 KB Output is correct
24 Correct 51 ms 49912 KB Output is correct
25 Correct 53 ms 49912 KB Output is correct
26 Correct 51 ms 49912 KB Output is correct
27 Correct 46 ms 50872 KB Output is correct
28 Correct 53 ms 50936 KB Output is correct
29 Correct 50 ms 51448 KB Output is correct
30 Correct 51 ms 51576 KB Output is correct
31 Correct 47 ms 51084 KB Output is correct
32 Correct 49 ms 51448 KB Output is correct
33 Correct 47 ms 51704 KB Output is correct
34 Correct 47 ms 51192 KB Output is correct
35 Correct 48 ms 51704 KB Output is correct
36 Correct 53 ms 51832 KB Output is correct
37 Correct 46 ms 49552 KB Output is correct
38 Correct 505 ms 67676 KB Output is correct
39 Correct 53 ms 49656 KB Output is correct
40 Correct 93 ms 54300 KB Output is correct
41 Correct 46 ms 49528 KB Output is correct
42 Correct 45 ms 49884 KB Output is correct
43 Correct 391 ms 67580 KB Output is correct
44 Correct 62 ms 51704 KB Output is correct
45 Correct 361 ms 67576 KB Output is correct
46 Correct 373 ms 67704 KB Output is correct
47 Correct 399 ms 67576 KB Output is correct
48 Correct 367 ms 67728 KB Output is correct
49 Correct 499 ms 67576 KB Output is correct
50 Correct 371 ms 67612 KB Output is correct
51 Correct 395 ms 67704 KB Output is correct
52 Correct 373 ms 67576 KB Output is correct
53 Correct 386 ms 67576 KB Output is correct
54 Correct 279 ms 67708 KB Output is correct
55 Correct 260 ms 67508 KB Output is correct
56 Correct 484 ms 67704 KB Output is correct
57 Correct 249 ms 67576 KB Output is correct
58 Correct 251 ms 67576 KB Output is correct
59 Correct 242 ms 67724 KB Output is correct
60 Correct 331 ms 67540 KB Output is correct
61 Correct 488 ms 67656 KB Output is correct
62 Correct 493 ms 67652 KB Output is correct
63 Correct 514 ms 67580 KB Output is correct
64 Correct 262 ms 67704 KB Output is correct
65 Correct 341 ms 67704 KB Output is correct
66 Correct 335 ms 67576 KB Output is correct
67 Correct 369 ms 67576 KB Output is correct
68 Correct 373 ms 67576 KB Output is correct
69 Correct 241 ms 67580 KB Output is correct
70 Correct 128 ms 62968 KB Output is correct
71 Correct 218 ms 67676 KB Output is correct
72 Correct 260 ms 67748 KB Output is correct
73 Correct 251 ms 67772 KB Output is correct
74 Correct 243 ms 67576 KB Output is correct
75 Correct 340 ms 67648 KB Output is correct
76 Correct 270 ms 67676 KB Output is correct
77 Correct 289 ms 67624 KB Output is correct
78 Correct 266 ms 67576 KB Output is correct
79 Correct 154 ms 67704 KB Output is correct
80 Correct 158 ms 67612 KB Output is correct
81 Correct 155 ms 67632 KB Output is correct
82 Correct 258 ms 67532 KB Output is correct
83 Correct 252 ms 67580 KB Output is correct
84 Correct 170 ms 67580 KB Output is correct
85 Correct 256 ms 67576 KB Output is correct
86 Correct 451 ms 67568 KB Output is correct
87 Correct 240 ms 67608 KB Output is correct
88 Correct 278 ms 67576 KB Output is correct
89 Correct 328 ms 67576 KB Output is correct
90 Correct 157 ms 62840 KB Output is correct
91 Correct 300 ms 67616 KB Output is correct
92 Correct 321 ms 67568 KB Output is correct
93 Correct 460 ms 67576 KB Output is correct
94 Correct 341 ms 67576 KB Output is correct
95 Correct 344 ms 67608 KB Output is correct
96 Correct 282 ms 67576 KB Output is correct
97 Correct 462 ms 67664 KB Output is correct
98 Correct 262 ms 67832 KB Output is correct
99 Correct 317 ms 67632 KB Output is correct
100 Correct 468 ms 67660 KB Output is correct