답안 #94306

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
94306 2019-01-17T12:44:01 Z Kastanda Bomb (IZhO17_bomb) C++11
47 / 100
1000 ms 56876 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];
int qu[N], F[N];
char A[N][N];
inline int Calc(int lenx)
{
    int Mn = n;
    for (int i = 1; i <= n; i++)
    {
        int l = 0, r = 0;
        for (int j = 1; j <= m; j++)
        {
            while (r - l && dn[i][j] <= dn[i][qu[r-1]])
                r --;
            qu[r ++] = j;
            if (qu[l] <= j - lenx)
                l ++;
            F[j - lenx + 1] = dn[i][qu[l]] - 1;
        }
        l = r = 0;
        for (int j = 1; j <= m; j++)
        {
            while (r - l && up[i][j] >= up[i][qu[r-1]])
                r --;
            qu[r ++] = j;
            if (qu[l] <= j - lenx)
                l ++;
            F[j - lenx + 1] -= up[i][qu[l]];
        }
        l = r = 0;
        for (int j = 1; j <= m; j++)
        {
            if (j + lenx - 1 <= m)
            {
                F[j] = max(F[j], 0);
                while (r - l && F[j] >= F[qu[r-1]])
                    r --;
                qu[r ++] = j;
            }
            while (qu[l] <= j - lenx)
                l ++;
            if (A[i][j] == '1')
                Mn = min(Mn, F[qu[l]]);
        }
    }
    return (Mn);
}
void Solve(int l = 1, int r = m)
{
    if (r - l + 1 <= 2)
        return ;
    if (R[l] == R[r])
    {
        for (int i = l + 1; i < r; i++)
            R[i] = R[l];
        return ;
    }
    int md = (l + r) >> 1;
    R[md] = Calc(md);
    Solve(l, md);
    Solve(md, r);
}
int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++)
        scanf("%s", &A[i][1]);

    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];

            if (A[i][j] == '0')
                dn[i][j] = 0, up[i][j] = n + 1;
        }
    R[1] = Calc(1);
    R[m] = Calc(m);
    Solve(1, m);
    int Mx_s = 0;
    for (int i = 1; i <= m; i++)
        Mx_s = max(Mx_s, i * R[i]);
    return !printf("%d", Mx_s);
}

Compilation message

bomb.cpp: In function 'int main()':
bomb.cpp:67: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:69: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 0 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 18 ms 26616 KB Output is correct
5 Correct 2 ms 376 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 508 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 476 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 3 ms 1016 KB Output is correct
18 Correct 3 ms 1144 KB Output is correct
19 Correct 4 ms 1320 KB Output is correct
20 Correct 4 ms 1400 KB Output is correct
21 Correct 3 ms 888 KB Output is correct
22 Correct 3 ms 1144 KB Output is correct
23 Correct 4 ms 1400 KB Output is correct
24 Correct 3 ms 1272 KB Output is correct
25 Correct 4 ms 1400 KB Output is correct
26 Correct 4 ms 1528 KB Output is correct
27 Correct 18 ms 4088 KB Output is correct
28 Correct 23 ms 4216 KB Output is correct
29 Correct 100 ms 5496 KB Output is correct
30 Correct 45 ms 6440 KB Output is correct
31 Correct 37 ms 5112 KB Output is correct
32 Correct 38 ms 5880 KB Output is correct
33 Correct 59 ms 6736 KB Output is correct
34 Correct 20 ms 4728 KB Output is correct
35 Correct 54 ms 6776 KB Output is correct
36 Correct 36 ms 6648 KB Output is correct
37 Correct 2 ms 504 KB Output is correct
38 Correct 192 ms 56680 KB Output is correct
39 Correct 2 ms 504 KB Output is correct
40 Correct 250 ms 16220 KB Output is correct
41 Correct 2 ms 504 KB Output is correct
42 Correct 8 ms 1400 KB Output is correct
43 Execution timed out 1070 ms 56700 KB Time limit exceeded
44 Correct 433 ms 6776 KB Output is correct
45 Execution timed out 1077 ms 56648 KB Time limit exceeded
46 Execution timed out 1065 ms 56736 KB Time limit exceeded
47 Execution timed out 1075 ms 56568 KB Time limit exceeded
48 Execution timed out 1087 ms 56696 KB Time limit exceeded
49 Execution timed out 1079 ms 56696 KB Time limit exceeded
50 Execution timed out 1071 ms 56568 KB Time limit exceeded
51 Execution timed out 1080 ms 56568 KB Time limit exceeded
52 Execution timed out 1073 ms 56568 KB Time limit exceeded
53 Execution timed out 1070 ms 56568 KB Time limit exceeded
54 Execution timed out 1072 ms 56648 KB Time limit exceeded
55 Execution timed out 1089 ms 56568 KB Time limit exceeded
56 Execution timed out 1079 ms 56832 KB Time limit exceeded
57 Execution timed out 1069 ms 56696 KB Time limit exceeded
58 Execution timed out 1080 ms 56568 KB Time limit exceeded
59 Execution timed out 1085 ms 56696 KB Time limit exceeded
60 Correct 958 ms 56824 KB Output is correct
61 Execution timed out 1067 ms 56876 KB Time limit exceeded
62 Correct 989 ms 56568 KB Output is correct
63 Correct 944 ms 56696 KB Output is correct
64 Correct 898 ms 56572 KB Output is correct
65 Execution timed out 1081 ms 56568 KB Time limit exceeded
66 Execution timed out 1083 ms 56568 KB Time limit exceeded
67 Execution timed out 1085 ms 56684 KB Time limit exceeded
68 Execution timed out 1066 ms 56696 KB Time limit exceeded
69 Execution timed out 1078 ms 56648 KB Time limit exceeded
70 Execution timed out 1068 ms 45304 KB Time limit exceeded
71 Execution timed out 1082 ms 56568 KB Time limit exceeded
72 Execution timed out 1094 ms 56568 KB Time limit exceeded
73 Execution timed out 1076 ms 56824 KB Time limit exceeded
74 Execution timed out 1076 ms 56824 KB Time limit exceeded
75 Execution timed out 1078 ms 56568 KB Time limit exceeded
76 Execution timed out 1070 ms 56704 KB Time limit exceeded
77 Execution timed out 1068 ms 56568 KB Time limit exceeded
78 Execution timed out 1077 ms 56700 KB Time limit exceeded
79 Execution timed out 1074 ms 56696 KB Time limit exceeded
80 Execution timed out 1086 ms 56672 KB Time limit exceeded
81 Execution timed out 1076 ms 56696 KB Time limit exceeded
82 Execution timed out 1082 ms 56568 KB Time limit exceeded
83 Execution timed out 1091 ms 56696 KB Time limit exceeded
84 Execution timed out 1082 ms 56696 KB Time limit exceeded
85 Execution timed out 1054 ms 56716 KB Time limit exceeded
86 Execution timed out 1075 ms 56568 KB Time limit exceeded
87 Execution timed out 1080 ms 56568 KB Time limit exceeded
88 Execution timed out 1082 ms 56824 KB Time limit exceeded
89 Execution timed out 1072 ms 56696 KB Time limit exceeded
90 Execution timed out 1074 ms 45692 KB Time limit exceeded
91 Execution timed out 1088 ms 56696 KB Time limit exceeded
92 Execution timed out 1077 ms 56696 KB Time limit exceeded
93 Execution timed out 1073 ms 56676 KB Time limit exceeded
94 Execution timed out 1086 ms 56568 KB Time limit exceeded
95 Execution timed out 1077 ms 56780 KB Time limit exceeded
96 Execution timed out 1073 ms 56664 KB Time limit exceeded
97 Execution timed out 1081 ms 56568 KB Time limit exceeded
98 Execution timed out 1081 ms 56440 KB Time limit exceeded
99 Execution timed out 1081 ms 56312 KB Time limit exceeded
100 Execution timed out 1081 ms 56184 KB Time limit exceeded