답안 #94315

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
94315 2019-01-17T13:51:22 Z Kastanda Bomb (IZhO17_bomb) C++11
100 / 100
127 ms 56952 KB
#include<bits/stdc++.h>
using namespace std;
const int N = 2505;
int n, m, Mnx, Mny, R[N], up[N][N], dn[N][N];
char A[N][N];
inline void Init()
{
    Mnx = m; Mny = n;

    for (int i = 1; i <= n; i++)
    {
        int last = 0;
        for (int j = 1; j <= m; j++)
            if (A[i][j] == '0')
            {
                if (last != j - 1)
                    Mnx = min(Mnx, j - last - 1);
                last = j;
            }
        if (last != m)
            Mnx = min(Mnx, m - last);
    }

    for (int i = 1; i <= m; i++)
    {
        int last = 0;
        for (int j = 1; j <= n; j++)
            if (A[j][i] == '0')
            {
                if (last != j - 1)
                    Mny = min(Mny, j - last - 1);
                last = j;
            }
        if (last != n)
            Mny = min(Mny, n - last);
    }
}
int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++)
        scanf("%s", &A[i][1]);
    Init();

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
        {
            up[i][j] = i - 1;
            if (A[i - 1][j] == '1')
                up[i][j] = up[i - 1][j];
        }
    for (int i = n; i; i--)
        for (int j = 1; j <= m; j++)
        {
            dn[i][j] = i + 1;
            if (A[i + 1][j] == '1')
                dn[i][j] = dn[i + 1][j];
        }
    for (int i = 0; i <= Mnx; i++)
        R[i] = Mny;
    for (int i = 1; i <= n; i++)
    {
        int l = 0, r = n + 1, c = 0;
        for (int j = 1; j <= m; j++)
        {
            if (A[i][j] == '1')
            {
                c ++;
                l = max(l, up[i][j]);
                r = min(r, dn[i][j]);
                R[c] = min(R[c], r - l - 1);
            }
            else
                l = 0, r = n + 1, c = 0;
        }
        l = 0, r = n + 1, c = 0;
        for (int j = m; j; j--)
        {
            if (A[i][j] == '1')
            {
                c ++;
                l = max(l, up[i][j]);
                r = min(r, dn[i][j]);
                R[c] = min(R[c], r - l - 1);
            }
            else
                l = 0, r = n + 1, c = 0;
        }
    }
    int Mx_s = 0;
    for (int i = 1; i <= Mnx; i++)
    {
        R[i] = min(R[i], R[i - 1]);
        Mx_s = max(Mx_s, i * R[i]);
    }
    return !printf("%d", Mx_s);
}

Compilation message

bomb.cpp: In function 'int main()':
bomb.cpp:40:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~
bomb.cpp:42:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s", &A[i][1]);
         ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 18 ms 26616 KB Output is correct
4 Correct 21 ms 26488 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 504 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 504 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 2 ms 504 KB Output is correct
17 Correct 2 ms 1016 KB Output is correct
18 Correct 2 ms 1016 KB Output is correct
19 Correct 2 ms 1404 KB Output is correct
20 Correct 2 ms 1400 KB Output is correct
21 Correct 2 ms 888 KB Output is correct
22 Correct 2 ms 1144 KB Output is correct
23 Correct 3 ms 1528 KB Output is correct
24 Correct 3 ms 1272 KB Output is correct
25 Correct 3 ms 1532 KB Output is correct
26 Correct 3 ms 1400 KB Output is correct
27 Correct 5 ms 4060 KB Output is correct
28 Correct 6 ms 4216 KB Output is correct
29 Correct 7 ms 5368 KB Output is correct
30 Correct 8 ms 6396 KB Output is correct
31 Correct 7 ms 5012 KB Output is correct
32 Correct 8 ms 5808 KB Output is correct
33 Correct 8 ms 6776 KB Output is correct
34 Correct 6 ms 4728 KB Output is correct
35 Correct 8 ms 6648 KB Output is correct
36 Correct 9 ms 6648 KB Output is correct
37 Correct 2 ms 504 KB Output is correct
38 Correct 115 ms 56312 KB Output is correct
39 Correct 2 ms 504 KB Output is correct
40 Correct 22 ms 15864 KB Output is correct
41 Correct 2 ms 504 KB Output is correct
42 Correct 3 ms 1400 KB Output is correct
43 Correct 118 ms 56184 KB Output is correct
44 Correct 8 ms 6648 KB Output is correct
45 Correct 119 ms 56184 KB Output is correct
46 Correct 127 ms 56432 KB Output is correct
47 Correct 118 ms 56184 KB Output is correct
48 Correct 123 ms 56356 KB Output is correct
49 Correct 106 ms 56184 KB Output is correct
50 Correct 109 ms 56376 KB Output is correct
51 Correct 118 ms 56184 KB Output is correct
52 Correct 111 ms 56288 KB Output is correct
53 Correct 117 ms 56156 KB Output is correct
54 Correct 111 ms 56156 KB Output is correct
55 Correct 115 ms 56200 KB Output is correct
56 Correct 124 ms 56184 KB Output is correct
57 Correct 117 ms 56312 KB Output is correct
58 Correct 113 ms 56212 KB Output is correct
59 Correct 105 ms 56248 KB Output is correct
60 Correct 102 ms 56184 KB Output is correct
61 Correct 108 ms 56184 KB Output is correct
62 Correct 112 ms 56320 KB Output is correct
63 Correct 111 ms 56156 KB Output is correct
64 Correct 101 ms 56268 KB Output is correct
65 Correct 105 ms 56196 KB Output is correct
66 Correct 113 ms 56184 KB Output is correct
67 Correct 124 ms 56184 KB Output is correct
68 Correct 117 ms 56188 KB Output is correct
69 Correct 110 ms 56312 KB Output is correct
70 Correct 78 ms 45012 KB Output is correct
71 Correct 108 ms 56312 KB Output is correct
72 Correct 116 ms 56184 KB Output is correct
73 Correct 119 ms 56312 KB Output is correct
74 Correct 118 ms 56844 KB Output is correct
75 Correct 109 ms 56744 KB Output is correct
76 Correct 115 ms 56872 KB Output is correct
77 Correct 111 ms 56848 KB Output is correct
78 Correct 121 ms 56764 KB Output is correct
79 Correct 117 ms 56772 KB Output is correct
80 Correct 107 ms 56796 KB Output is correct
81 Correct 111 ms 56816 KB Output is correct
82 Correct 117 ms 56796 KB Output is correct
83 Correct 111 ms 56920 KB Output is correct
84 Correct 113 ms 56796 KB Output is correct
85 Correct 118 ms 56824 KB Output is correct
86 Correct 117 ms 56952 KB Output is correct
87 Correct 115 ms 56768 KB Output is correct
88 Correct 115 ms 56824 KB Output is correct
89 Correct 111 ms 56888 KB Output is correct
90 Correct 76 ms 45732 KB Output is correct
91 Correct 115 ms 56824 KB Output is correct
92 Correct 114 ms 56844 KB Output is correct
93 Correct 116 ms 56876 KB Output is correct
94 Correct 119 ms 56868 KB Output is correct
95 Correct 106 ms 56824 KB Output is correct
96 Correct 118 ms 56824 KB Output is correct
97 Correct 117 ms 56868 KB Output is correct
98 Correct 116 ms 56824 KB Output is correct
99 Correct 115 ms 56792 KB Output is correct
100 Correct 118 ms 56780 KB Output is correct