CSES - IZhO 2017, day 2 - Results
Submission details
Task:Bomb
Sender:Yytsi
Submission time:2019-02-11 10:02:21 +0200
Language:C++
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED1
#2ACCEPTED1
#3ACCEPTED1
#4ACCEPTED1
#5ACCEPTED1
#6ACCEPTED1
#7ACCEPTED1
#8ACCEPTED1
#9ACCEPTED1
#10ACCEPTED1
#11ACCEPTED1
#12ACCEPTED1
#13ACCEPTED1
#14ACCEPTED1
#15ACCEPTED1
#16ACCEPTED1
#17ACCEPTED1
#18ACCEPTED1
#19ACCEPTED1
#20ACCEPTED1
#21ACCEPTED1
#22ACCEPTED1
#23ACCEPTED1
#24ACCEPTED1
#25ACCEPTED1
#26ACCEPTED1
#27ACCEPTED1
#28ACCEPTED1
#29ACCEPTED1
#30ACCEPTED1
#31ACCEPTED1
#32ACCEPTED1
#33ACCEPTED1
#34ACCEPTED1
#35ACCEPTED1
#36ACCEPTED1
#37ACCEPTED1
#38ACCEPTED1
#39ACCEPTED1
#40ACCEPTED1
#41ACCEPTED1
#42ACCEPTED1
#43ACCEPTED1
#44ACCEPTED1
#45ACCEPTED1
#46ACCEPTED1
#47ACCEPTED1
#48ACCEPTED1
#49ACCEPTED1
#50ACCEPTED1
#51ACCEPTED1
#52ACCEPTED1
#53ACCEPTED1
#54ACCEPTED1
#55ACCEPTED1
#56ACCEPTED1
#57ACCEPTED1
#58ACCEPTED1
#59ACCEPTED1
#60ACCEPTED1
#61ACCEPTED1
#62ACCEPTED1
#63ACCEPTED1
#64ACCEPTED1
#65ACCEPTED1
#66ACCEPTED1
#67ACCEPTED1
#68ACCEPTED1
#69ACCEPTED1
#70ACCEPTED1
#71ACCEPTED1
#72ACCEPTED1
#73ACCEPTED1
#74ACCEPTED1
#75ACCEPTED1
#76ACCEPTED1
#77ACCEPTED1
#78ACCEPTED1
#79ACCEPTED1
#80ACCEPTED1
#81ACCEPTED1
#82ACCEPTED1
#83ACCEPTED1
#84ACCEPTED1
#85ACCEPTED1
#86ACCEPTED1
#87ACCEPTED1
#88ACCEPTED1
#89ACCEPTED1
#90ACCEPTED1
#91ACCEPTED1
#92ACCEPTED1
#93ACCEPTED1
#94ACCEPTED1
#95ACCEPTED1
#96ACCEPTED1
#97ACCEPTED1
#98ACCEPTED1
#99ACCEPTED1
#100ACCEPTED1
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1details
#2ACCEPTED0.02 s2details
#3ACCEPTED0.03 s3details
#4ACCEPTED0.04 s4details
#5ACCEPTED0.02 s5details
#6ACCEPTED0.02 s6details
#7ACCEPTED0.02 s7details
#8ACCEPTED0.02 s8details
#9ACCEPTED0.01 s9details
#10ACCEPTED0.02 s10details
#11ACCEPTED0.02 s11details
#12ACCEPTED0.01 s12details
#13ACCEPTED0.02 s13details
#14ACCEPTED0.01 s14details
#15ACCEPTED0.02 s15details
#16ACCEPTED0.02 s16details
#17ACCEPTED0.03 s17details
#18ACCEPTED0.01 s18details
#19ACCEPTED0.02 s19details
#20ACCEPTED0.01 s20details
#21ACCEPTED0.03 s21details
#22ACCEPTED0.01 s22details
#23ACCEPTED0.01 s23details
#24ACCEPTED0.03 s24details
#25ACCEPTED0.02 s25details
#26ACCEPTED0.02 s26details
#27ACCEPTED0.03 s27details
#28ACCEPTED0.03 s28details
#29ACCEPTED0.03 s29details
#30ACCEPTED0.02 s30details
#31ACCEPTED0.03 s31details
#32ACCEPTED0.03 s32details
#33ACCEPTED0.04 s33details
#34ACCEPTED0.02 s34details
#35ACCEPTED0.03 s35details
#36ACCEPTED0.03 s36details
#37ACCEPTED0.01 s37details
#38ACCEPTED0.34 s38details
#39ACCEPTED0.01 s39details
#40ACCEPTED0.06 s40details
#41ACCEPTED0.01 s41details
#42ACCEPTED0.02 s42details
#43ACCEPTED0.28 s43details
#44ACCEPTED0.02 s44details
#45ACCEPTED0.28 s45details
#46ACCEPTED0.27 s46details
#47ACCEPTED0.29 s47details
#48ACCEPTED0.27 s48details
#49ACCEPTED0.33 s49details
#50ACCEPTED0.28 s50details
#51ACCEPTED0.28 s51details
#52ACCEPTED0.27 s52details
#53ACCEPTED0.27 s53details
#54ACCEPTED0.23 s54details
#55ACCEPTED0.22 s55details
#56ACCEPTED0.33 s56details
#57ACCEPTED0.22 s57details
#58ACCEPTED0.22 s58details
#59ACCEPTED0.22 s59details
#60ACCEPTED0.26 s60details
#61ACCEPTED0.33 s61details
#62ACCEPTED0.33 s62details
#63ACCEPTED0.33 s63details
#64ACCEPTED0.22 s64details
#65ACCEPTED0.27 s65details
#66ACCEPTED0.28 s66details
#67ACCEPTED0.27 s67details
#68ACCEPTED0.28 s68details
#69ACCEPTED0.22 s69details
#70ACCEPTED0.11 s70details
#71ACCEPTED0.20 s71details
#72ACCEPTED0.21 s72details
#73ACCEPTED0.23 s73details
#74ACCEPTED0.24 s74details
#75ACCEPTED0.24 s75details
#76ACCEPTED0.22 s76details
#77ACCEPTED0.23 s77details
#78ACCEPTED0.23 s78details
#79ACCEPTED0.16 s79details
#80ACCEPTED0.16 s80details
#81ACCEPTED0.17 s81details
#82ACCEPTED0.23 s82details
#83ACCEPTED0.23 s83details
#84ACCEPTED0.15 s84details
#85ACCEPTED0.23 s85details
#86ACCEPTED0.31 s86details
#87ACCEPTED0.23 s87details
#88ACCEPTED0.24 s88details
#89ACCEPTED0.25 s89details
#90ACCEPTED0.14 s90details
#91ACCEPTED0.25 s91details
#92ACCEPTED0.26 s92details
#93ACCEPTED0.31 s93details
#94ACCEPTED0.26 s94details
#95ACCEPTED0.24 s95details
#96ACCEPTED0.23 s96details
#97ACCEPTED0.33 s97details
#98ACCEPTED0.24 s98details
#99ACCEPTED0.26 s99details
#100ACCEPTED0.32 s100details

Code

// It works locally :(


#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define IO ios_base::sync_with_stdio(0); cin.tie(0)
#define F first
#define S second
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define N 2505
bool A[N][N];
int dp[N][N];
int up[N][N], down[N][N];
int mx_height[N];

int n, m;

int scanline(int y) {
  // Scan minimum constraint for width.
  int mn = 1e9;
  int c = 0;
  FOR(x,1,m+1) {
    if (A[y][x]) {
      c++;
    } else {
      if (c == 0) continue;
      mn = min(mn, c);
      c = 0;
    }
  }

  if (c != 0) mn = min(c, mn);

  return mn;
}

int scancol(int x) {
  // Scan minimum constraint for height.
  int mn = 1e9;
  int c = 0;
  FOR(y,1,n+1) {
    if (A[y][x]) {
      c++;
    } else {
      if (c == 0) continue;
      mn = min(mn, c);
      c = 0;
    }
  }

  if (c != 0) mn = min(c, mn);

  return mn;
}



int main() {
  IO; cin>>n>>m;
  FOR(y,1,n+1) {
    FOR(x,1,m+1) {
      char c; cin>>c;
      if (c == '1') A[y][x] = true;
    }
  }

  int H = n, W = m;
  FOR(y,1,n+1) {
    int r = scanline(y);
    if (r == 1e9) continue;
    W = min(W, r);
  }

  FOR(x,1,m+1) {
    int r = scancol(x);
    if (r == 1e9) continue;
    H = min(H, r);
  }

  FOR(x,1,m+1) {
    for (int y = n; y >= 1; y--) {
      if (A[y][x]) down[y][x] = down[y+1][x] + 1;
    }

    FOR(y,1,n+1) {
      if (A[y][x]) up[y][x] = up[y-1][x] + 1;
    }
  }

  FOR(w,1,W+1) mx_height[w] = H;
  FOR(y,1,n+1) {
    int idx = 0, u = 1e9, d = 1e9;

    FOR(x,1,m+1) {
      if (A[y][x]) {
        // Increase width
        u = min(u, up[y][x]);
        d = min(d, down[y][x]);
        ++idx;
        mx_height[idx] = min(mx_height[idx], u+d-1);
      } else {
        u = d = 1e9;
        idx = 0;
      }
    }

    d = u = 1e9; idx = 0;
    for (int x = m; x >= 1; x--) {
      if (A[y][x]) {
        // Increase width
        u = min(u, up[y][x]);
        d = min(d, down[y][x]);
        ++idx;
        mx_height[idx] = min(mx_height[idx], u+d-1);
      } else {
        u = d = 1e9;
        idx = 0;
      }
    }
  }

  int ans = 0;
  int cr = mx_height[1];
  FOR(w,1,W+1) {
    cr = min(cr, mx_height[w]);
    ans = max(ans, w * cr);
  }

  cout<<ans<<"\n";
}

Test details

Test 1

Group: 1

Verdict: ACCEPTED

input
1 20
00001111101110011110

correct output
3

user output
3

Test 2

Group: 2

Verdict: ACCEPTED

input
20 1
1
1
1
0
...

correct output
2

user output
2

Test 3

Group: 3

Verdict: ACCEPTED

input
2499 1
1
1
1
1
...

correct output
38

user output
38

Test 4

Group: 4

Verdict: ACCEPTED

input
2499 1
1
1
1
1
...

correct output
55

user output
55

Test 5

Group: 5

Verdict: ACCEPTED

input
1 2500
111111111110111111111110111111...

correct output
7

user output
7

Test 6

Group: 6

Verdict: ACCEPTED

input
1 1000
111111111111111111111111111111...

correct output
33

user output
33

Test 7

Group: 7

Verdict: ACCEPTED

input
5 5
11111
11111
11011
11111
...

correct output
4

user output
4

Test 8

Group: 8

Verdict: ACCEPTED

input
20 20
11111000000000000000
11111000000000000000
11111100000000000000
11111111111000000000
...

correct output
8

user output
8

Test 9

Group: 9

Verdict: ACCEPTED

input
20 20
11111100000000000000
11111100000000000000
11111110000000000000
11111111111110000000
...

correct output
12

user output
12

Test 10

Group: 10

Verdict: ACCEPTED

input
14 13
0000011100000
0000011100000
0000011100000
0000011110000
...

correct output
4

user output
4

Test 11

Group: 11

Verdict: ACCEPTED

input
20 19
1111110000000000000
1111111000000000000
1111111000000000000
1111111000000000000
...

correct output
10

user output
10

Test 12

Group: 12

Verdict: ACCEPTED

input
15 15
110000000000000
110000000000000
110000000000000
111000000000000
...

correct output
2

user output
2

Test 13

Group: 13

Verdict: ACCEPTED

input
15 11
00111000000
00111000000
00111000000
00111000000
...

correct output
3

user output
3

Test 14

Group: 14

Verdict: ACCEPTED

input
16 16
0000111100001111
0000111100001111
0000111100001111
0000111100001111
...

correct output
16

user output
16

Test 15

Group: 15

Verdict: ACCEPTED

input
18 18
111110000000000000
111110000000000000
111110000000000000
111111000000000000
...

correct output
8

user output
8

Test 16

Group: 16

Verdict: ACCEPTED

input
20 20
11111111111111011111
11111111111111011111
11111111111111011111
11111111111111111111
...

correct output
20

user output
20

Test 17

Group: 17

Verdict: ACCEPTED

input
65 70
000000000000000011111000000000...

correct output
15

user output
15

Test 18

Group: 18

Verdict: ACCEPTED

input
70 62
111100000000000000000000000000...

correct output
6

user output
6

Test 19

Group: 19

Verdict: ACCEPTED

input
94 78
111111111111111100000000000000...

correct output
22

user output
22

Test 20

Group: 20

Verdict: ACCEPTED

input
92 84
111111111111111110000000000000...

correct output
27

user output
27

Test 21

Group: 21

Verdict: ACCEPTED

input
53 89
000001111000000000000000000000...

correct output
6

user output
6

Test 22

Group: 22

Verdict: ACCEPTED

input
76 93
000011111100000000000000000000...

correct output
12

user output
12

Test 23

Group: 23

Verdict: ACCEPTED

input
100 100
111111111111111111111111111111...

correct output
209

user output
209

Test 24

Group: 24

Verdict: ACCEPTED

input
81 74
111111111111111110000000000000...

correct output
30

user output
30

Test 25

Group: 25

Verdict: ACCEPTED

input
100 100
111111111111111111111111111111...

correct output
80

user output
80

Test 26

Group: 26

Verdict: ACCEPTED

input
100 100
111111111111111111111111111111...

correct output
132

user output
132

Test 27

Group: 27

Verdict: ACCEPTED

input
295 268
111111111111111111111111111111...

correct output
3

user output
3

Test 28

Group: 28

Verdict: ACCEPTED

input
290 383
111111110000000000000000000000...

correct output
20

user output
20

Test 29

Group: 29

Verdict: ACCEPTED

input
390 320
000000000000000000000000000000...

correct output
3038

user output
3038

Test 30

Group: 30

Verdict: ACCEPTED

input
432 434
111111111111111111111111111111...

correct output
221

user output
221

Test 31

Group: 31

Verdict: ACCEPTED

input
334 450
111111111111111111111111111111...

correct output
391

user output
391

Test 32

Group: 32

Verdict: ACCEPTED

input
407 383
111111111111111111111111111111...

correct output
156

user output
156

Test 33

Group: 33

Verdict: ACCEPTED

input
450 450
111111111111111111111111111111...

correct output
1235

user output
1235

Test 34

Group: 34

Verdict: ACCEPTED

input
356 231
000000000001111111111110000000...

correct output
42

user output
42

Test 35

Group: 35

Verdict: ACCEPTED

input
450 450
111111111111111111111111111111...

correct output
192

user output
192

Test 36

Group: 36

Verdict: ACCEPTED

input
450 450
111111111111111111111111111111...

correct output
1404

user output
1404

Test 37

Group: 37

Verdict: ACCEPTED

input
20 20
00000000001111111111
00000000001111111111
00000000001111111111
00000000001111111111
...

correct output
14

user output
14

Test 38

Group: 38

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
6250000

user output
6250000

Test 39

Group: 39

Verdict: ACCEPTED

input
20 20
00000000001111111111
00000000001111111111
00000000111111111111
00000001111111111111
...

correct output
24

user output
24

Test 40

Group: 40

Verdict: ACCEPTED

input
875 882
111111111111111111111111111111...

correct output
69552

user output
69552

Test 41

Group: 41

Verdict: ACCEPTED

input
20 20
00000000111111111111
00000011111111111111
00000011111111111111
00000111111111111111
...

correct output
36

user output
36

Test 42

Group: 42

Verdict: ACCEPTED

input
100 100
000000000000000000000000000000...

correct output
651

user output
651

Test 43

Group: 43

Verdict: ACCEPTED

input
2500 2500
000000000000000000000000000000...

correct output
250500

user output
250500

Test 44

Group: 44

Verdict: ACCEPTED

input
450 450
000000000000000000000000000000...

correct output
12864

user output
12864

Test 45

Group: 45

Verdict: ACCEPTED

input
2500 2500
000000000000000000000000000000...

correct output
399456

user output
399456

Test 46

Group: 46

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111100000...

correct output
625

user output
625

Test 47

Group: 47

Verdict: ACCEPTED

input
2500 2500
000000000000000000000000000000...

correct output
395486

user output
395486

Test 48

Group: 48

Verdict: ACCEPTED

input
2500 2500
000000000000000000000000000000...

correct output
3360

user output
3360

Test 49

Group: 49

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
28

user output
28

Test 50

Group: 50

Verdict: ACCEPTED

input
2500 2500
000000000000000000000000000000...

correct output
7348

user output
7348

Test 51

Group: 51

Verdict: ACCEPTED

input
2500 2500
000000000000000000000000000000...

correct output
6622

user output
6622

Test 52

Group: 52

Verdict: ACCEPTED

input
2500 2500
000000000000000000000000000000...

correct output
5593

user output
5593

Test 53

Group: 53

Verdict: ACCEPTED

input
2500 2500
000000000000000000000000000000...

correct output
4545

user output
4545

Test 54

Group: 54

Verdict: ACCEPTED

input
2500 2500
000000000000000000000000000000...

correct output
4067

user output
4067

Test 55

Group: 55

Verdict: ACCEPTED

input
2500 2500
000000000000000000000000000000...

correct output
2806

user output
2806

Test 56

Group: 56

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
122500

user output
122500

Test 57

Group: 57

Verdict: ACCEPTED

input
2500 2500
000000000000000000000000000000...

correct output
4674

user output
4674

Test 58

Group: 58

Verdict: ACCEPTED

input
2500 2500
000000000000000000000000000000...

correct output
6272

user output
6272

Test 59

Group: 59

Verdict: ACCEPTED

input
2500 2500
000000000000000000000000000000...

correct output
3337

user output
3337

Test 60

Group: 60

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
870

user output
870

Test 61

Group: 61

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
532

user output
532

Test 62

Group: 62

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
114271

user output
114271

Test 63

Group: 63

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
1560001

user output
1560001

Test 64

Group: 64

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
62500

user output
62500

Test 65

Group: 65

Verdict: ACCEPTED

input
2500 2500
000000000000000000000000000000...

correct output
1400

user output
1400

Test 66

Group: 66

Verdict: ACCEPTED

input
2500 2500
000000111111111111111111111111...

correct output
9910

user output
9910

Test 67

Group: 67

Verdict: ACCEPTED

input
2500 2500
000000000000000000000000000000...

correct output
9879

user output
9879

Test 68

Group: 68

Verdict: ACCEPTED

input
2500 2500
000000000000000000000000000000...

correct output
16224

user output
16224

Test 69

Group: 69

Verdict: ACCEPTED

input
2500 2500
000000000000000000000000000000...

correct output
6300

user output
6300

Test 70

Group: 70

Verdict: ACCEPTED

input
2000 2000
111111111111111111111111111111...

correct output
59760

user output
59760

Test 71

Group: 71

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
40480

user output
40480

Test 72

Group: 72

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
137159

user output
137159

Test 73

Group: 73

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
32110

user output
32110

Test 74

Group: 74

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
10914

user output
10914

Test 75

Group: 75

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
124074

user output
124074

Test 76

Group: 76

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
4617

user output
4617

Test 77

Group: 77

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
106981

user output
106981

Test 78

Group: 78

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
44980

user output
44980

Test 79

Group: 79

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111110000...

correct output
1365

user output
1365

Test 80

Group: 80

Verdict: ACCEPTED

input
2500 2500
111111111111111111110000000000...

correct output
602

user output
602

Test 81

Group: 81

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
2709

user output
2709

Test 82

Group: 82

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
149556

user output
149556

Test 83

Group: 83

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
11289

user output
11289

Test 84

Group: 84

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
366

user output
366

Test 85

Group: 85

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
4814

user output
4814

Test 86

Group: 86

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
132

user output
132

Test 87

Group: 87

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
589

user output
589

Test 88

Group: 88

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
56448

user output
56448

Test 89

Group: 89

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
10044

user output
10044

Test 90

Group: 90

Verdict: ACCEPTED

input
2000 2000
111111111111111111111111111111...

correct output
6384

user output
6384

Test 91

Group: 91

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
15330

user output
15330

Test 92

Group: 92

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
47759

user output
47759

Test 93

Group: 93

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
624

user output
624

Test 94

Group: 94

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
16695

user output
16695

Test 95

Group: 95

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
19224

user output
19224

Test 96

Group: 96

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
89386

user output
89386

Test 97

Group: 97

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
243

user output
243

Test 98

Group: 98

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
73840

user output
73840

Test 99

Group: 99

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
10764

user output
10764

Test 100

Group: 100

Verdict: ACCEPTED

input
2500 2500
111111111111111111111111111111...

correct output
135

user output
135