Submission #944659

# Submission time Handle Problem Language Result Execution time Memory
944659 2024-03-13T02:44:48 Z GrandTiger1729 Bomb (IZhO17_bomb) C++17
33 / 100
68 ms 38392 KB
#include <bits/stdc++.h>
using namespace std;

const int INF = 1e9;
int main()
{
    cin.tie(0)->sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    vector<string> g(n);
    for (int i = 0; i < n; i++)
    {
        cin >> g[i];
    }
    vector<int> res(n, INF);
    for (int tt = 0; tt < 2; tt++)
    {
        vector<vector<int>> rr(n, vector<int>(m));
        for (int i = 0; i < n; i++)
        {
            int cur = m;
            for (int j = m - 1; j >= 0; j--)
            {
                if (g[i][j] == '0')
                {
                    cur = j;
                }
                rr[i][j] = cur;
            }
        }
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < m; j++)
            {
                if (g[i][j] == '1' && (i == 0 || g[i - 1][j] == '0') && (j == 0 || g[i][j - 1] == '0'))
                {
                    int k = i, cur = INF;
                    while (k < n && k - i < res.size() && g[k][j] == '1')
                    {
                        cur = min(cur, rr[k][j] - j);
                        res[k - i] = min(res[k - i], cur);
                        k++;
                    }
                    res.resize(k - i);
                }
            }
        }
        reverse(g.begin(), g.end());
        for (int i = 0; i < n; i++)
        {
            reverse(g[i].begin(), g[i].end());
        }
    }
    int ans = 0;
    for (int i = 0; i < res.size(); i++)
    {
        ans = max(ans, (i + 1) * res[i]);
    }
    cout << ans << '\n';
    return 0;
}

Compilation message

bomb.cpp: In function 'int main()':
bomb.cpp:38:43: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |                     while (k < n && k - i < res.size() && g[k][j] == '1')
      |                                     ~~~~~~^~~~~~~~~~~~
bomb.cpp:55:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for (int i = 0; i < res.size(); i++)
      |                     ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Incorrect 1 ms 348 KB Output isn't correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Correct 0 ms 348 KB Output is correct
11 Incorrect 0 ms 348 KB Output isn't correct
12 Incorrect 1 ms 348 KB Output isn't correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 456 KB Output is correct
15 Incorrect 1 ms 344 KB Output isn't correct
16 Correct 0 ms 420 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Incorrect 0 ms 344 KB Output isn't correct
20 Incorrect 1 ms 348 KB Output isn't correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Incorrect 1 ms 344 KB Output isn't correct
24 Incorrect 0 ms 348 KB Output isn't correct
25 Incorrect 0 ms 348 KB Output isn't correct
26 Incorrect 0 ms 348 KB Output isn't correct
27 Incorrect 1 ms 884 KB Output isn't correct
28 Incorrect 1 ms 1124 KB Output isn't correct
29 Incorrect 2 ms 1116 KB Output isn't correct
30 Incorrect 2 ms 1524 KB Output isn't correct
31 Incorrect 2 ms 1156 KB Output isn't correct
32 Incorrect 2 ms 1384 KB Output isn't correct
33 Incorrect 2 ms 1628 KB Output isn't correct
34 Incorrect 1 ms 980 KB Output isn't correct
35 Incorrect 2 ms 1628 KB Output isn't correct
36 Incorrect 2 ms 1620 KB Output isn't correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 58 ms 37780 KB Output is correct
39 Correct 0 ms 344 KB Output is correct
40 Incorrect 8 ms 5108 KB Output isn't correct
41 Correct 1 ms 532 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 67 ms 37760 KB Output is correct
44 Correct 2 ms 1624 KB Output is correct
45 Correct 61 ms 37724 KB Output is correct
46 Correct 62 ms 37772 KB Output is correct
47 Correct 61 ms 37716 KB Output is correct
48 Correct 54 ms 37848 KB Output is correct
49 Incorrect 57 ms 37896 KB Output isn't correct
50 Incorrect 55 ms 37816 KB Output isn't correct
51 Incorrect 55 ms 37716 KB Output isn't correct
52 Correct 55 ms 37724 KB Output is correct
53 Incorrect 53 ms 37716 KB Output isn't correct
54 Correct 55 ms 38148 KB Output is correct
55 Incorrect 56 ms 37716 KB Output isn't correct
56 Correct 68 ms 37852 KB Output is correct
57 Incorrect 58 ms 37716 KB Output isn't correct
58 Correct 57 ms 37724 KB Output is correct
59 Correct 58 ms 37888 KB Output is correct
60 Incorrect 57 ms 37848 KB Output isn't correct
61 Incorrect 60 ms 37848 KB Output isn't correct
62 Incorrect 63 ms 37764 KB Output isn't correct
63 Incorrect 60 ms 37712 KB Output isn't correct
64 Incorrect 60 ms 37716 KB Output isn't correct
65 Correct 60 ms 37712 KB Output is correct
66 Incorrect 58 ms 37716 KB Output isn't correct
67 Correct 59 ms 37712 KB Output is correct
68 Incorrect 63 ms 37844 KB Output isn't correct
69 Correct 57 ms 37720 KB Output is correct
70 Incorrect 35 ms 24400 KB Output isn't correct
71 Incorrect 57 ms 37716 KB Output isn't correct
72 Incorrect 57 ms 38228 KB Output isn't correct
73 Incorrect 55 ms 37824 KB Output isn't correct
74 Incorrect 59 ms 37712 KB Output isn't correct
75 Incorrect 56 ms 37712 KB Output isn't correct
76 Incorrect 56 ms 37836 KB Output isn't correct
77 Incorrect 56 ms 37712 KB Output isn't correct
78 Incorrect 57 ms 37844 KB Output isn't correct
79 Incorrect 56 ms 37836 KB Output isn't correct
80 Incorrect 54 ms 37712 KB Output isn't correct
81 Incorrect 54 ms 37896 KB Output isn't correct
82 Incorrect 55 ms 37884 KB Output isn't correct
83 Incorrect 55 ms 37896 KB Output isn't correct
84 Incorrect 54 ms 37848 KB Output isn't correct
85 Incorrect 55 ms 37716 KB Output isn't correct
86 Incorrect 62 ms 37812 KB Output isn't correct
87 Incorrect 56 ms 37844 KB Output isn't correct
88 Incorrect 60 ms 38044 KB Output isn't correct
89 Incorrect 55 ms 37716 KB Output isn't correct
90 Incorrect 35 ms 24404 KB Output isn't correct
91 Incorrect 59 ms 37712 KB Output isn't correct
92 Incorrect 54 ms 37716 KB Output isn't correct
93 Incorrect 62 ms 37848 KB Output isn't correct
94 Incorrect 58 ms 37716 KB Output isn't correct
95 Incorrect 52 ms 37716 KB Output isn't correct
96 Incorrect 58 ms 37844 KB Output isn't correct
97 Incorrect 67 ms 37780 KB Output isn't correct
98 Incorrect 59 ms 38392 KB Output isn't correct
99 Incorrect 61 ms 37848 KB Output isn't correct
100 Incorrect 65 ms 37712 KB Output isn't correct