답안 #854579

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
854579 2023-09-28T05:59:24 Z The_Samurai Bomb (IZhO17_bomb) C++17
29 / 100
1000 ms 32380 KB
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const int inf = 1e9, N = 1e6 + 5;

int main() {
    cin.tie(0)->sync_with_stdio(false);
#ifdef sunnatov
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
//    freopen("game.in", "r", stdin);
//    freopen("game.out", "w", stdout);
#endif

    int n, m;
    cin >> n >> m;
    vector<vector<char>> a(n + 1, vector<char>(m + 1));
    vector<vector<int>> pref(n + 1, vector<int>(m + 1));
    for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) {
        cin >> a[i][j];
        pref[i][j] = pref[i][j - 1] + pref[i - 1][j] - pref[i - 1][j - 1] + (int) (a[i][j] == '1');
    }
    auto get_sum = [&](int x1, int y1, int x2, int y2) {
        return pref[x2][y2] - pref[x2][y1 - 1] - pref[x1 - 1][y2] + pref[x1 - 1][y1 - 1];
    };
    auto check = [&](int h, int w) {
        vector<vector<bool>> vis(n + 1, vector<bool>(m + 1));
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                if (a[i][j] == '0') continue;
                if (i + h - 1 <= n and j + w - 1 <= m and get_sum(i, j, i + h - 1, j + w - 1) == h * w) {
                    for (int x = i; x < i + h; x++) {
                        for (int y = j; y < j + w; y++) {
                            vis[x][y] = true;
                        }
                    }
                }
                if (!vis[i][j]) return false;
            }
        }
        return true;
    };
    vector<int> v(n + 1, -1);
    auto get = [&](int h) {
        if (v[h] != -1) return v[h];
        int lx = 1, rx = m, best = 0;
        while (lx <= rx) {
            int mid = (lx + rx) >> 1;
            if (check(h, mid)) {
                best = mid;
                lx = mid + 1;
            } else {
                rx = mid - 1;
            }
        }
        return v[h] = best;
    };
    get(1);
    for (int i = 2; i <= n; i++) {
        if (get(i) * i < get(i - 1) * (i - 1)) {
            cout << get(i - 1) * (i - 1);
            return 0;
        }
    }
    cout << get(n) * n;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 6 ms 860 KB Output is correct
4 Correct 9 ms 860 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 600 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 6 ms 348 KB Output is correct
24 Incorrect 1 ms 344 KB Output isn't correct
25 Incorrect 1 ms 348 KB Output isn't correct
26 Correct 28 ms 348 KB Output is correct
27 Correct 3 ms 1112 KB Output is correct
28 Correct 3 ms 860 KB Output is correct
29 Execution timed out 1090 ms 1096 KB Time limit exceeded
30 Incorrect 18 ms 1788 KB Output isn't correct
31 Incorrect 11 ms 1116 KB Output isn't correct
32 Incorrect 7 ms 1116 KB Output isn't correct
33 Execution timed out 1072 ms 1372 KB Time limit exceeded
34 Correct 4 ms 856 KB Output is correct
35 Incorrect 11 ms 1540 KB Output isn't correct
36 Execution timed out 1047 ms 1620 KB Time limit exceeded
37 Correct 0 ms 348 KB Output is correct
38 Execution timed out 1091 ms 31988 KB Time limit exceeded
39 Correct 1 ms 348 KB Output is correct
40 Execution timed out 1089 ms 4316 KB Time limit exceeded
41 Incorrect 0 ms 348 KB Output isn't correct
42 Incorrect 95 ms 348 KB Output isn't correct
43 Execution timed out 1036 ms 31988 KB Time limit exceeded
44 Execution timed out 1051 ms 1492 KB Time limit exceeded
45 Execution timed out 1052 ms 32080 KB Time limit exceeded
46 Execution timed out 1075 ms 32368 KB Time limit exceeded
47 Execution timed out 1058 ms 31984 KB Time limit exceeded
48 Execution timed out 1020 ms 32136 KB Time limit exceeded
49 Execution timed out 1033 ms 32140 KB Time limit exceeded
50 Execution timed out 1026 ms 32140 KB Time limit exceeded
51 Execution timed out 1102 ms 32136 KB Time limit exceeded
52 Execution timed out 1020 ms 32240 KB Time limit exceeded
53 Execution timed out 1041 ms 32144 KB Time limit exceeded
54 Execution timed out 1066 ms 32372 KB Time limit exceeded
55 Execution timed out 1036 ms 32356 KB Time limit exceeded
56 Execution timed out 1062 ms 32176 KB Time limit exceeded
57 Execution timed out 1036 ms 32140 KB Time limit exceeded
58 Execution timed out 1041 ms 32132 KB Time limit exceeded
59 Execution timed out 1055 ms 32080 KB Time limit exceeded
60 Execution timed out 1068 ms 32144 KB Time limit exceeded
61 Execution timed out 1061 ms 32356 KB Time limit exceeded
62 Execution timed out 1081 ms 32084 KB Time limit exceeded
63 Execution timed out 1022 ms 31968 KB Time limit exceeded
64 Execution timed out 1055 ms 32356 KB Time limit exceeded
65 Execution timed out 1054 ms 32236 KB Time limit exceeded
66 Execution timed out 1025 ms 32080 KB Time limit exceeded
67 Execution timed out 1016 ms 32268 KB Time limit exceeded
68 Execution timed out 1016 ms 32080 KB Time limit exceeded
69 Execution timed out 1064 ms 32084 KB Time limit exceeded
70 Execution timed out 1035 ms 20948 KB Time limit exceeded
71 Execution timed out 1027 ms 32136 KB Time limit exceeded
72 Execution timed out 1062 ms 32144 KB Time limit exceeded
73 Execution timed out 1058 ms 32140 KB Time limit exceeded
74 Execution timed out 1044 ms 32148 KB Time limit exceeded
75 Execution timed out 1057 ms 32148 KB Time limit exceeded
76 Execution timed out 1069 ms 32132 KB Time limit exceeded
77 Execution timed out 1028 ms 32140 KB Time limit exceeded
78 Execution timed out 1041 ms 32368 KB Time limit exceeded
79 Execution timed out 1060 ms 32244 KB Time limit exceeded
80 Incorrect 119 ms 32136 KB Output isn't correct
81 Incorrect 500 ms 32380 KB Output isn't correct
82 Execution timed out 1080 ms 32144 KB Time limit exceeded
83 Execution timed out 1076 ms 32264 KB Time limit exceeded
84 Incorrect 152 ms 32196 KB Output isn't correct
85 Execution timed out 1074 ms 32084 KB Time limit exceeded
86 Execution timed out 1043 ms 32140 KB Time limit exceeded
87 Execution timed out 1067 ms 32136 KB Time limit exceeded
88 Execution timed out 1080 ms 32132 KB Time limit exceeded
89 Execution timed out 1065 ms 31984 KB Time limit exceeded
90 Execution timed out 1034 ms 20792 KB Time limit exceeded
91 Execution timed out 1033 ms 32144 KB Time limit exceeded
92 Execution timed out 1037 ms 32080 KB Time limit exceeded
93 Execution timed out 1016 ms 32144 KB Time limit exceeded
94 Execution timed out 1054 ms 32080 KB Time limit exceeded
95 Execution timed out 1063 ms 32120 KB Time limit exceeded
96 Execution timed out 1072 ms 32348 KB Time limit exceeded
97 Execution timed out 1068 ms 32136 KB Time limit exceeded
98 Execution timed out 1064 ms 32140 KB Time limit exceeded
99 Execution timed out 1058 ms 31984 KB Time limit exceeded
100 Execution timed out 1069 ms 32140 KB Time limit exceeded