Submission #833274

# Submission time Handle Problem Language Result Execution time Memory
833274 2023-08-22T03:59:06 Z vjudge1 Bomb (IZhO17_bomb) C++17
24 / 100
171 ms 24920 KB
#include <bits/stdc++.h>
using namespace std;

const int MX = 2505;
int N, M;
int A[MX][MX];

int solve(vector<int> v) {
      int mn = 1e9;

      vector<int> lf(v.size()), rg(v.size());

      for(int i = 0; i < v.size(); i++) {
            if(v[i] == 1) {
                  if(i - 1 < 0 || v[i - 1] == 0) lf[i] = i;
                  else lf[i] = lf[i - 1];
            }
      }

      for(int i = v.size() - 1; i >= 0; i--) {
            if(v[i] == 1) {
                  if(i + 1 == v.size() || v[i + 1] == 0) rg[i] = i;
                  else rg[i] = rg[i + 1];
            }
      }

      for(int i = 0; i < v.size(); i++) {
            if(v[i] == 1) {
                  mn = min(mn, rg[i] - lf[i] + 1);
            }
      }

      return mn;
}

int main() {
      cin.tie(0); ios_base::sync_with_stdio(0);

      cin >> N >> M;
      for(int i = 0; i < N; i++) {
            for(int j = 0; j < M; j++) {
                  char c;
                  cin >> c;
                  if(c == '1') A[i][j] = 1;
            }
      }

      int minRow = 1e9, minCol = 1e9;
      for(int i = 0; i < N; i++) {
            vector<int> v;
            for(int j = 0; j < M; j++) v.push_back(A[i][j]);
            minRow = min(minRow, solve(v));
      }

      for(int j = 0; j < M; j++) {
            vector<int> v;
            for(int i = 0; i < N; i++) v.push_back(A[i][j]);
            minCol = min(minCol, solve(v));
      }

      cout << minRow * minCol << '\n';
}

Compilation message

bomb.cpp: In function 'int solve(std::vector<int>)':
bomb.cpp:13:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |       for(int i = 0; i < v.size(); i++) {
      |                      ~~^~~~~~~~~~
bomb.cpp:22:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |                   if(i + 1 == v.size() || v[i + 1] == 0) rg[i] = i;
      |                      ~~~~~~^~~~~~~~~~~
bomb.cpp:27:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |       for(int i = 0; i < v.size(); i++) {
      |                      ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 4 ms 10312 KB Output is correct
4 Correct 4 ms 10392 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Incorrect 0 ms 340 KB Output isn't correct
9 Incorrect 0 ms 340 KB Output isn't correct
10 Incorrect 0 ms 340 KB Output isn't correct
11 Incorrect 0 ms 340 KB Output isn't correct
12 Incorrect 0 ms 340 KB Output isn't correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Incorrect 1 ms 340 KB Output isn't correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Incorrect 0 ms 468 KB Output isn't correct
19 Incorrect 1 ms 468 KB Output isn't correct
20 Incorrect 1 ms 468 KB Output isn't correct
21 Incorrect 0 ms 340 KB Output isn't correct
22 Incorrect 1 ms 468 KB Output isn't correct
23 Incorrect 1 ms 468 KB Output isn't correct
24 Incorrect 1 ms 468 KB Output isn't correct
25 Incorrect 1 ms 596 KB Output isn't correct
26 Correct 1 ms 724 KB Output is correct
27 Correct 3 ms 1748 KB Output is correct
28 Incorrect 2 ms 468 KB Output isn't correct
29 Incorrect 4 ms 2260 KB Output isn't correct
30 Incorrect 6 ms 1716 KB Output isn't correct
31 Incorrect 4 ms 1236 KB Output isn't correct
32 Incorrect 4 ms 1620 KB Output isn't correct
33 Incorrect 5 ms 2132 KB Output isn't correct
34 Incorrect 2 ms 596 KB Output isn't correct
35 Incorrect 4 ms 596 KB Output isn't correct
36 Correct 6 ms 2900 KB Output is correct
37 Incorrect 1 ms 340 KB Output isn't correct
38 Correct 170 ms 24860 KB Output is correct
39 Incorrect 0 ms 340 KB Output isn't correct
40 Incorrect 20 ms 6868 KB Output isn't correct
41 Incorrect 0 ms 340 KB Output isn't correct
42 Incorrect 1 ms 724 KB Output isn't correct
43 Correct 160 ms 22936 KB Output is correct
44 Incorrect 5 ms 2516 KB Output isn't correct
45 Incorrect 160 ms 23596 KB Output isn't correct
46 Correct 155 ms 24864 KB Output is correct
47 Incorrect 156 ms 23572 KB Output isn't correct
48 Incorrect 151 ms 24780 KB Output isn't correct
49 Correct 171 ms 24864 KB Output is correct
50 Incorrect 159 ms 24768 KB Output isn't correct
51 Incorrect 154 ms 24920 KB Output isn't correct
52 Incorrect 159 ms 24844 KB Output isn't correct
53 Incorrect 153 ms 24528 KB Output isn't correct
54 Incorrect 136 ms 18124 KB Output isn't correct
55 Incorrect 146 ms 17292 KB Output isn't correct
56 Correct 162 ms 24820 KB Output is correct
57 Incorrect 154 ms 14916 KB Output isn't correct
58 Incorrect 157 ms 17372 KB Output isn't correct
59 Incorrect 139 ms 15740 KB Output isn't correct
60 Correct 165 ms 20764 KB Output is correct
61 Correct 168 ms 24816 KB Output is correct
62 Correct 167 ms 24860 KB Output is correct
63 Correct 168 ms 24864 KB Output is correct
64 Correct 147 ms 16288 KB Output is correct
65 Incorrect 155 ms 24324 KB Output isn't correct
66 Incorrect 162 ms 22776 KB Output isn't correct
67 Incorrect 160 ms 24820 KB Output isn't correct
68 Incorrect 159 ms 24864 KB Output isn't correct
69 Incorrect 135 ms 14668 KB Output isn't correct
70 Incorrect 76 ms 5360 KB Output isn't correct
71 Incorrect 127 ms 11116 KB Output isn't correct
72 Incorrect 147 ms 13880 KB Output isn't correct
73 Incorrect 141 ms 14052 KB Output isn't correct
74 Incorrect 138 ms 14812 KB Output isn't correct
75 Incorrect 141 ms 15736 KB Output isn't correct
76 Incorrect 140 ms 16420 KB Output isn't correct
77 Incorrect 142 ms 16640 KB Output isn't correct
78 Incorrect 142 ms 16756 KB Output isn't correct
79 Incorrect 120 ms 2940 KB Output isn't correct
80 Incorrect 118 ms 3676 KB Output isn't correct
81 Incorrect 147 ms 3868 KB Output isn't correct
82 Incorrect 160 ms 17968 KB Output isn't correct
83 Incorrect 143 ms 18176 KB Output isn't correct
84 Incorrect 124 ms 692 KB Output isn't correct
85 Incorrect 157 ms 17700 KB Output isn't correct
86 Incorrect 170 ms 24308 KB Output isn't correct
87 Incorrect 136 ms 17028 KB Output isn't correct
88 Incorrect 151 ms 17380 KB Output isn't correct
89 Incorrect 164 ms 21772 KB Output isn't correct
90 Incorrect 87 ms 12380 KB Output isn't correct
91 Incorrect 141 ms 19388 KB Output isn't correct
92 Incorrect 150 ms 20156 KB Output isn't correct
93 Incorrect 169 ms 23768 KB Output isn't correct
94 Incorrect 151 ms 21172 KB Output isn't correct
95 Incorrect 147 ms 18048 KB Output isn't correct
96 Incorrect 151 ms 17948 KB Output isn't correct
97 Incorrect 164 ms 24136 KB Output isn't correct
98 Incorrect 137 ms 17852 KB Output isn't correct
99 Incorrect 143 ms 20872 KB Output isn't correct
100 Incorrect 164 ms 23628 KB Output isn't correct