Submission #655753

# Submission time Handle Problem Language Result Execution time Memory
655753 2022-11-05T14:06:57 Z someone Bomb (IZhO17_bomb) C++14
0 / 100
72 ms 131072 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
 
const int N = 2.5e3 + 42, INF = 1e18 + 42;

bool alien[N*N];
vector<int> add[N*N];
int n, m, t[N*N], id[N][N], sz[N*N];

int F(int i) {
    if(sz[i] < 0)
        return i;
    return sz[i] = F(sz[i]);
}

int getSz(int i) {
    return -sz[F(i)];
}

void U(int a, int b) {
    a = F(a), b = F(b);
    if(a == b)
        return;
    if(-sz[a] < -sz[b])
        swap(a, b);
    sz[a] += sz[b];
    sz[b] = a;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    for(int& p : sz)
        p = -1;
    
    cin >> n >> m;
    
    n++, m++;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            id[i][j] = m * i + j;
    for(int i = 1; i < n; i++)
        for(int j = 1; j < m; j++) {
            char c; c = '1';//cin >> c;
            alien[id[i][j]] = (c == '1');
        }
    
    int minLen = INF;
    for(int i = 1; i < n; i++)
        for(int j = 1; j < m; j++)
            if(alien[id[i][j]]) {
                t[id[i][j]] = t[id[i][j]-1] + 1;
                add[t[id[i][j]]].push_back(id[i][j]);
                if(j == m || !alien[id[i][j]+1])
                    minLen = min(minLen, t[id[i][j]]);
            }
    
    int ans = 0;
    multiset<int> len;
    for(int i = N*N-1; i > 0; i--) {
        for(int j : add[i]) {
            if(t[j - m] >= t[j]) {
                len.erase(len.find(getSz(j - m)));
                U(j - m, j);
            }
            if(t[j + m] > t[j]) {
                len.erase(len.find(getSz(j + m)));
                U(j + m, j);
            }
            len.insert(getSz(j));
        }
        if(i <= minLen) {
            auto it = len.begin();
            ans = max(ans, (*it) * i);
        }
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 51 ms 131072 KB Execution killed with signal 9
2 Runtime error 52 ms 131072 KB Execution killed with signal 9
3 Runtime error 57 ms 131072 KB Execution killed with signal 9
4 Runtime error 53 ms 131072 KB Execution killed with signal 9
5 Runtime error 72 ms 131072 KB Execution killed with signal 9
6 Runtime error 58 ms 131072 KB Execution killed with signal 9
7 Runtime error 59 ms 131072 KB Execution killed with signal 9
8 Runtime error 55 ms 131072 KB Execution killed with signal 9
9 Runtime error 67 ms 131072 KB Execution killed with signal 9
10 Runtime error 56 ms 131072 KB Execution killed with signal 9
11 Runtime error 57 ms 131072 KB Execution killed with signal 9
12 Runtime error 53 ms 131072 KB Execution killed with signal 9
13 Runtime error 55 ms 131072 KB Execution killed with signal 9
14 Runtime error 55 ms 131072 KB Execution killed with signal 9
15 Runtime error 54 ms 131072 KB Execution killed with signal 9
16 Runtime error 59 ms 131072 KB Execution killed with signal 9
17 Runtime error 56 ms 131072 KB Execution killed with signal 9
18 Runtime error 61 ms 131072 KB Execution killed with signal 9
19 Runtime error 55 ms 131072 KB Execution killed with signal 9
20 Runtime error 62 ms 131072 KB Execution killed with signal 9
21 Runtime error 59 ms 131072 KB Execution killed with signal 9
22 Runtime error 56 ms 131072 KB Execution killed with signal 9
23 Runtime error 53 ms 131072 KB Execution killed with signal 9
24 Runtime error 52 ms 131072 KB Execution killed with signal 9
25 Runtime error 52 ms 131072 KB Execution killed with signal 9
26 Runtime error 55 ms 131072 KB Execution killed with signal 9
27 Runtime error 59 ms 131072 KB Execution killed with signal 9
28 Runtime error 54 ms 131072 KB Execution killed with signal 9
29 Runtime error 65 ms 131072 KB Execution killed with signal 9
30 Runtime error 51 ms 131072 KB Execution killed with signal 9
31 Runtime error 52 ms 131072 KB Execution killed with signal 9
32 Runtime error 69 ms 131072 KB Execution killed with signal 9
33 Runtime error 59 ms 131072 KB Execution killed with signal 9
34 Runtime error 52 ms 131072 KB Execution killed with signal 9
35 Runtime error 65 ms 131072 KB Execution killed with signal 9
36 Runtime error 52 ms 131072 KB Execution killed with signal 9
37 Runtime error 57 ms 131072 KB Execution killed with signal 9
38 Runtime error 59 ms 131072 KB Execution killed with signal 9
39 Runtime error 71 ms 131072 KB Execution killed with signal 9
40 Runtime error 61 ms 131072 KB Execution killed with signal 9
41 Runtime error 55 ms 131072 KB Execution killed with signal 9
42 Runtime error 64 ms 131072 KB Execution killed with signal 9
43 Runtime error 52 ms 131072 KB Execution killed with signal 9
44 Runtime error 58 ms 131072 KB Execution killed with signal 9
45 Runtime error 58 ms 131072 KB Execution killed with signal 9
46 Runtime error 69 ms 131072 KB Execution killed with signal 9
47 Runtime error 51 ms 131072 KB Execution killed with signal 9
48 Runtime error 51 ms 131072 KB Execution killed with signal 9
49 Runtime error 62 ms 131072 KB Execution killed with signal 9
50 Runtime error 54 ms 131072 KB Execution killed with signal 9
51 Runtime error 51 ms 131072 KB Execution killed with signal 9
52 Runtime error 51 ms 131072 KB Execution killed with signal 9
53 Runtime error 51 ms 131072 KB Execution killed with signal 9
54 Runtime error 56 ms 131072 KB Execution killed with signal 9
55 Runtime error 60 ms 131072 KB Execution killed with signal 9
56 Runtime error 54 ms 131072 KB Execution killed with signal 9
57 Runtime error 57 ms 131072 KB Execution killed with signal 9
58 Runtime error 57 ms 131072 KB Execution killed with signal 9
59 Runtime error 52 ms 131072 KB Execution killed with signal 9
60 Runtime error 61 ms 131072 KB Execution killed with signal 9
61 Runtime error 67 ms 131072 KB Execution killed with signal 9
62 Runtime error 56 ms 131072 KB Execution killed with signal 9
63 Runtime error 68 ms 131072 KB Execution killed with signal 9
64 Runtime error 58 ms 131072 KB Execution killed with signal 9
65 Runtime error 59 ms 131072 KB Execution killed with signal 9
66 Runtime error 61 ms 131072 KB Execution killed with signal 9
67 Runtime error 52 ms 131072 KB Execution killed with signal 9
68 Runtime error 53 ms 131072 KB Execution killed with signal 9
69 Runtime error 56 ms 131072 KB Execution killed with signal 9
70 Runtime error 53 ms 131072 KB Execution killed with signal 9
71 Runtime error 59 ms 131072 KB Execution killed with signal 9
72 Runtime error 61 ms 131072 KB Execution killed with signal 9
73 Runtime error 59 ms 131072 KB Execution killed with signal 9
74 Runtime error 51 ms 131072 KB Execution killed with signal 9
75 Runtime error 56 ms 131072 KB Execution killed with signal 9
76 Runtime error 52 ms 131072 KB Execution killed with signal 9
77 Runtime error 52 ms 131072 KB Execution killed with signal 9
78 Runtime error 53 ms 131072 KB Execution killed with signal 9
79 Runtime error 69 ms 131072 KB Execution killed with signal 9
80 Runtime error 63 ms 131072 KB Execution killed with signal 9
81 Runtime error 63 ms 131072 KB Execution killed with signal 9
82 Runtime error 63 ms 131072 KB Execution killed with signal 9
83 Runtime error 54 ms 131072 KB Execution killed with signal 9
84 Runtime error 53 ms 131072 KB Execution killed with signal 9
85 Runtime error 57 ms 131072 KB Execution killed with signal 9
86 Runtime error 60 ms 131072 KB Execution killed with signal 9
87 Runtime error 62 ms 131072 KB Execution killed with signal 9
88 Runtime error 69 ms 131072 KB Execution killed with signal 9
89 Runtime error 53 ms 131072 KB Execution killed with signal 9
90 Runtime error 54 ms 131072 KB Execution killed with signal 9
91 Runtime error 52 ms 131072 KB Execution killed with signal 9
92 Runtime error 57 ms 131072 KB Execution killed with signal 9
93 Runtime error 68 ms 131072 KB Execution killed with signal 9
94 Runtime error 53 ms 131072 KB Execution killed with signal 9
95 Runtime error 56 ms 131072 KB Execution killed with signal 9
96 Runtime error 55 ms 131072 KB Execution killed with signal 9
97 Runtime error 52 ms 131072 KB Execution killed with signal 9
98 Runtime error 56 ms 131072 KB Execution killed with signal 9
99 Runtime error 53 ms 131072 KB Execution killed with signal 9
100 Runtime error 59 ms 131072 KB Execution killed with signal 9