Submission #35059

# Submission time Handle Problem Language Result Execution time Memory
35059 2017-11-17T20:40:32 Z model_code Bomb (IZhO17_bomb) C++14
100 / 100
769 ms 63304 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:20: 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:45: 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 19 ms 63304 KB Output is correct
2 Correct 13 ms 63304 KB Output is correct
3 Correct 19 ms 63304 KB Output is correct
4 Correct 16 ms 63304 KB Output is correct
5 Correct 13 ms 63304 KB Output is correct
6 Correct 16 ms 63304 KB Output is correct
7 Correct 13 ms 63304 KB Output is correct
8 Correct 13 ms 63304 KB Output is correct
9 Correct 16 ms 63304 KB Output is correct
10 Correct 13 ms 63304 KB Output is correct
11 Correct 16 ms 63304 KB Output is correct
12 Correct 16 ms 63304 KB Output is correct
13 Correct 16 ms 63304 KB Output is correct
14 Correct 13 ms 63304 KB Output is correct
15 Correct 13 ms 63304 KB Output is correct
16 Correct 16 ms 63304 KB Output is correct
17 Correct 19 ms 63304 KB Output is correct
18 Correct 13 ms 63304 KB Output is correct
19 Correct 16 ms 63304 KB Output is correct
20 Correct 13 ms 63304 KB Output is correct
21 Correct 16 ms 63304 KB Output is correct
22 Correct 19 ms 63304 KB Output is correct
23 Correct 13 ms 63304 KB Output is correct
24 Correct 13 ms 63304 KB Output is correct
25 Correct 23 ms 63304 KB Output is correct
26 Correct 16 ms 63304 KB Output is correct
27 Correct 13 ms 63304 KB Output is correct
28 Correct 13 ms 63304 KB Output is correct
29 Correct 23 ms 63304 KB Output is correct
30 Correct 13 ms 63304 KB Output is correct
31 Correct 19 ms 63304 KB Output is correct
32 Correct 23 ms 63304 KB Output is correct
33 Correct 19 ms 63304 KB Output is correct
34 Correct 16 ms 63304 KB Output is correct
35 Correct 16 ms 63304 KB Output is correct
36 Correct 23 ms 63304 KB Output is correct
37 Correct 9 ms 63304 KB Output is correct
38 Correct 769 ms 63304 KB Output is correct
39 Correct 16 ms 63304 KB Output is correct
40 Correct 83 ms 63304 KB Output is correct
41 Correct 13 ms 63304 KB Output is correct
42 Correct 16 ms 63304 KB Output is correct
43 Correct 549 ms 63304 KB Output is correct
44 Correct 19 ms 63304 KB Output is correct
45 Correct 533 ms 63304 KB Output is correct
46 Correct 449 ms 63304 KB Output is correct
47 Correct 513 ms 63304 KB Output is correct
48 Correct 496 ms 63304 KB Output is correct
49 Correct 756 ms 63304 KB Output is correct
50 Correct 496 ms 63304 KB Output is correct
51 Correct 479 ms 63304 KB Output is correct
52 Correct 493 ms 63304 KB Output is correct
53 Correct 483 ms 63304 KB Output is correct
54 Correct 316 ms 63304 KB Output is correct
55 Correct 329 ms 63304 KB Output is correct
56 Correct 746 ms 63304 KB Output is correct
57 Correct 336 ms 63304 KB Output is correct
58 Correct 306 ms 63304 KB Output is correct
59 Correct 323 ms 63304 KB Output is correct
60 Correct 469 ms 63304 KB Output is correct
61 Correct 746 ms 63304 KB Output is correct
62 Correct 759 ms 63304 KB Output is correct
63 Correct 763 ms 63304 KB Output is correct
64 Correct 299 ms 63304 KB Output is correct
65 Correct 466 ms 63304 KB Output is correct
66 Correct 493 ms 63304 KB Output is correct
67 Correct 549 ms 63304 KB Output is correct
68 Correct 569 ms 63304 KB Output is correct
69 Correct 303 ms 63304 KB Output is correct
70 Correct 149 ms 63304 KB Output is correct
71 Correct 246 ms 63304 KB Output is correct
72 Correct 306 ms 63304 KB Output is correct
73 Correct 349 ms 63304 KB Output is correct
74 Correct 306 ms 63304 KB Output is correct
75 Correct 296 ms 63304 KB Output is correct
76 Correct 289 ms 63304 KB Output is correct
77 Correct 316 ms 63304 KB Output is correct
78 Correct 296 ms 63304 KB Output is correct
79 Correct 136 ms 63304 KB Output is correct
80 Correct 146 ms 63304 KB Output is correct
81 Correct 153 ms 63304 KB Output is correct
82 Correct 356 ms 63304 KB Output is correct
83 Correct 313 ms 63304 KB Output is correct
84 Correct 126 ms 63304 KB Output is correct
85 Correct 293 ms 63304 KB Output is correct
86 Correct 663 ms 63304 KB Output is correct
87 Correct 296 ms 63304 KB Output is correct
88 Correct 326 ms 63304 KB Output is correct
89 Correct 436 ms 63304 KB Output is correct
90 Correct 176 ms 63304 KB Output is correct
91 Correct 366 ms 63304 KB Output is correct
92 Correct 416 ms 63304 KB Output is correct
93 Correct 736 ms 63304 KB Output is correct
94 Correct 456 ms 63304 KB Output is correct
95 Correct 359 ms 63304 KB Output is correct
96 Correct 389 ms 63304 KB Output is correct
97 Correct 706 ms 63304 KB Output is correct
98 Correct 346 ms 63304 KB Output is correct
99 Correct 439 ms 63304 KB Output is correct
100 Correct 676 ms 63304 KB Output is correct