Submission #515942

# Submission time Handle Problem Language Result Execution time Memory
515942 2022-01-20T07:25:22 Z Be_dos Bomb (IZhO17_bomb) C++17
16 / 100
1000 ms 131076 KB
#include <iostream>
#include <cmath>
#include <cctype>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <stack>
#include <unordered_set>
#include <sstream>
#include <cstring>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <random>
#include <cfloat>
#include <chrono>
#include <bitset>
#include <complex>
#include <immintrin.h>
#include <cassert>

bool good(std::string* str, int32_t n, int32_t m, int32_t ans_h, int32_t ans_w) {
    int32_t** sums = new int32_t*[n];
    for(int32_t i = 0; i < n; i++) {
        sums[i] = new int32_t[m];
        for(int32_t j = 0; j < m; j++)
            sums[i][j] = 0;
    }

    for(int32_t i = 0; i <= n - ans_h; i++) {
        for(int32_t j = 0; j <= m - ans_w; j++) {
            int32_t sum = 0;
            for(int32_t k = i; k < i + ans_h; k++)
                for(int32_t q = j; q < j + ans_w; q++) {
                    sum += str[k][q] - '0';
                }
            if(sum != ans_h * ans_w)
                continue;

            for(int32_t k = i; k < i + ans_h; k++)
                for(int32_t q = j; q < j + ans_w; q++) {
                    sums[k][q]++;
                }
        }
    }

    bool good = true;
    for(int32_t i = 0; i < n; i++)
        for(int32_t j = 0 ;j < m; j++)
            if(str[i][j] == '1' && sums[i][j] == 0)
                good = false;
    return good;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int32_t n, m;
    std::cin >> n >> m;

    std::mt19937 rng;
    for(int32_t z = 0; z < 1; z++) {
        std::string* str = new std::string[n];
        for(int32_t i = 0; i < n; i++)
            std::cin >> str[i];
            //for(int32_t j = 0; j < m; j++)
            //    str[i].push_back(rng() % 10 < 9 ? '1' : '0');

        int32_t ans = 0;
        for(int32_t i = 1; i <= n; i++)
            for(int32_t j = 1; j <= m; j++)
                if(good(str, n, m, i, j))
                    ans = std::max(ans, i * j);
        std::cout << ans << "\n";
    }
    return 0;
}





# Verdict Execution time Memory Grader output
1 Correct 0 ms 312 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Execution timed out 1082 ms 58628 KB Time limit exceeded
4 Execution timed out 1092 ms 67252 KB Time limit exceeded
5 Execution timed out 1090 ms 14180 KB Time limit exceeded
6 Correct 153 ms 4312 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 3 ms 1080 KB Output is correct
9 Correct 3 ms 1100 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 3 ms 972 KB Output is correct
12 Correct 1 ms 588 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 1 ms 588 KB Output is correct
15 Correct 2 ms 800 KB Output is correct
16 Correct 4 ms 1100 KB Output is correct
17 Execution timed out 1093 ms 43416 KB Time limit exceeded
18 Execution timed out 1073 ms 43340 KB Time limit exceeded
19 Execution timed out 1095 ms 47720 KB Time limit exceeded
20 Execution timed out 1085 ms 48664 KB Time limit exceeded
21 Execution timed out 1087 ms 42540 KB Time limit exceeded
22 Execution timed out 1091 ms 47480 KB Time limit exceeded
23 Execution timed out 1093 ms 52504 KB Time limit exceeded
24 Execution timed out 1094 ms 45724 KB Time limit exceeded
25 Execution timed out 1088 ms 53156 KB Time limit exceeded
26 Execution timed out 1040 ms 39220 KB Time limit exceeded
27 Execution timed out 1050 ms 79136 KB Time limit exceeded
28 Execution timed out 1080 ms 91612 KB Time limit exceeded
29 Execution timed out 1083 ms 74212 KB Time limit exceeded
30 Execution timed out 1018 ms 96268 KB Time limit exceeded
31 Execution timed out 1066 ms 88512 KB Time limit exceeded
32 Execution timed out 1028 ms 94372 KB Time limit exceeded
33 Execution timed out 1072 ms 91780 KB Time limit exceeded
34 Execution timed out 1065 ms 110236 KB Time limit exceeded
35 Execution timed out 1075 ms 105340 KB Time limit exceeded
36 Execution timed out 1052 ms 71824 KB Time limit exceeded
37 Correct 3 ms 1096 KB Output is correct
38 Runtime error 277 ms 131076 KB Execution killed with signal 9
39 Correct 3 ms 1100 KB Output is correct
40 Execution timed out 1063 ms 129300 KB Time limit exceeded
41 Correct 4 ms 1076 KB Output is correct
42 Execution timed out 1065 ms 48216 KB Time limit exceeded
43 Runtime error 239 ms 131076 KB Execution killed with signal 9
44 Execution timed out 1052 ms 85528 KB Time limit exceeded
45 Runtime error 241 ms 131076 KB Execution killed with signal 9
46 Runtime error 267 ms 131076 KB Execution killed with signal 9
47 Runtime error 246 ms 131076 KB Execution killed with signal 9
48 Runtime error 263 ms 131076 KB Execution killed with signal 9
49 Runtime error 271 ms 131076 KB Execution killed with signal 9
50 Runtime error 241 ms 131076 KB Execution killed with signal 9
51 Runtime error 233 ms 131076 KB Execution killed with signal 9
52 Runtime error 232 ms 131076 KB Execution killed with signal 9
53 Runtime error 238 ms 131076 KB Execution killed with signal 9
54 Runtime error 220 ms 131076 KB Execution killed with signal 9
55 Runtime error 214 ms 131076 KB Execution killed with signal 9
56 Runtime error 290 ms 131076 KB Execution killed with signal 9
57 Runtime error 207 ms 131076 KB Execution killed with signal 9
58 Runtime error 223 ms 131076 KB Execution killed with signal 9
59 Runtime error 209 ms 131076 KB Execution killed with signal 9
60 Runtime error 254 ms 131076 KB Execution killed with signal 9
61 Runtime error 267 ms 131076 KB Execution killed with signal 9
62 Runtime error 294 ms 131076 KB Execution killed with signal 9
63 Runtime error 280 ms 131076 KB Execution killed with signal 9
64 Runtime error 274 ms 131076 KB Execution killed with signal 9
65 Runtime error 240 ms 131076 KB Execution killed with signal 9
66 Runtime error 261 ms 131076 KB Execution killed with signal 9
67 Runtime error 246 ms 131076 KB Execution killed with signal 9
68 Runtime error 240 ms 131076 KB Execution killed with signal 9
69 Runtime error 214 ms 131076 KB Execution killed with signal 9
70 Runtime error 215 ms 131076 KB Execution killed with signal 9
71 Runtime error 204 ms 131076 KB Execution killed with signal 9
72 Runtime error 217 ms 131076 KB Execution killed with signal 9
73 Runtime error 240 ms 131076 KB Execution killed with signal 9
74 Runtime error 204 ms 131076 KB Execution killed with signal 9
75 Runtime error 207 ms 131076 KB Execution killed with signal 9
76 Runtime error 219 ms 131076 KB Execution killed with signal 9
77 Runtime error 206 ms 131076 KB Execution killed with signal 9
78 Runtime error 232 ms 131076 KB Execution killed with signal 9
79 Runtime error 172 ms 131076 KB Execution killed with signal 9
80 Runtime error 174 ms 131076 KB Execution killed with signal 9
81 Runtime error 176 ms 131076 KB Execution killed with signal 9
82 Runtime error 221 ms 131076 KB Execution killed with signal 9
83 Runtime error 207 ms 131076 KB Execution killed with signal 9
84 Runtime error 196 ms 131076 KB Execution killed with signal 9
85 Runtime error 227 ms 131076 KB Execution killed with signal 9
86 Runtime error 268 ms 131076 KB Execution killed with signal 9
87 Runtime error 203 ms 131076 KB Execution killed with signal 9
88 Runtime error 213 ms 131076 KB Execution killed with signal 9
89 Runtime error 230 ms 131076 KB Execution killed with signal 9
90 Runtime error 314 ms 131076 KB Execution killed with signal 9
91 Runtime error 266 ms 131076 KB Execution killed with signal 9
92 Runtime error 226 ms 131076 KB Execution killed with signal 9
93 Runtime error 268 ms 131076 KB Execution killed with signal 9
94 Runtime error 244 ms 131076 KB Execution killed with signal 9
95 Runtime error 247 ms 131076 KB Execution killed with signal 9
96 Runtime error 214 ms 131076 KB Execution killed with signal 9
97 Runtime error 302 ms 131076 KB Execution killed with signal 9
98 Runtime error 244 ms 131076 KB Execution killed with signal 9
99 Runtime error 248 ms 131076 KB Execution killed with signal 9
100 Runtime error 278 ms 131076 KB Execution killed with signal 9