답안 #655768

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
655768 2022-11-05T14:21:51 Z someone Bomb (IZhO17_bomb) C++14
13 / 100
1000 ms 103672 KB
#include <bits/stdc++.h>
//#define int long long
using namespace std;

struct Alien {
    int t, id;
};
 
const int N = 2500 + 42, INF = 1e9 + 42;

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

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

inline 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 = 1; i < n; i++)
        for(int j = 1; j < m; j++) {
            char c; cin >> c;
            alien[m * i + j] = (c == '1');
        }
    
    int minLen = INF;
    for(int i = 1; i < n; i++)
        for(int j = 1; j < m; j++)
            if(alien[m * i + j]) {
                int id = m * i + j;
                t[j] = t[j-1] + 1;
                alien[id] = false;
                add.push_back({t[j], id});
                if(j == m || !alien[id+1])
                    minLen = min(minLen, t[j]);
            }
    
    sort(add.begin(), add.end(),
    [](Alien a, Alien b) {
        if(a.t == b.t)
            return a.id < b.id;
        return a.t > b.t;
    });
    
    int ans = 0;
    multiset<int> len;
    for(Alien a : add) {
        int i = a.t, j = a.id;
        alien[j] = true;
        if(alien[j - m]) {
            len.erase(len.find(getSz(j - m)));
            U(j - m, j);
        }
        if(alien[j + m]) {
            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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 25556 KB Output is correct
2 Incorrect 11 ms 25556 KB Output isn't correct
3 Incorrect 11 ms 25628 KB Output isn't correct
4 Incorrect 11 ms 25684 KB Output isn't correct
5 Correct 11 ms 25732 KB Output is correct
6 Correct 11 ms 25624 KB Output is correct
7 Correct 11 ms 25556 KB Output is correct
8 Incorrect 12 ms 25556 KB Output isn't correct
9 Incorrect 14 ms 25548 KB Output isn't correct
10 Incorrect 11 ms 25608 KB Output isn't correct
11 Incorrect 10 ms 25556 KB Output isn't correct
12 Incorrect 11 ms 25632 KB Output isn't correct
13 Correct 12 ms 25624 KB Output is correct
14 Correct 10 ms 25636 KB Output is correct
15 Incorrect 11 ms 25560 KB Output isn't correct
16 Incorrect 11 ms 25568 KB Output isn't correct
17 Incorrect 12 ms 25556 KB Output isn't correct
18 Incorrect 12 ms 25524 KB Output isn't correct
19 Incorrect 11 ms 25636 KB Output isn't correct
20 Incorrect 12 ms 25640 KB Output isn't correct
21 Incorrect 11 ms 25556 KB Output isn't correct
22 Incorrect 10 ms 25536 KB Output isn't correct
23 Incorrect 11 ms 25576 KB Output isn't correct
24 Incorrect 12 ms 25556 KB Output isn't correct
25 Incorrect 12 ms 25648 KB Output isn't correct
26 Correct 17 ms 25812 KB Output is correct
27 Correct 25 ms 26900 KB Output is correct
28 Incorrect 11 ms 25812 KB Output isn't correct
29 Incorrect 29 ms 27080 KB Output isn't correct
30 Incorrect 20 ms 26540 KB Output isn't correct
31 Incorrect 17 ms 26200 KB Output isn't correct
32 Incorrect 15 ms 26192 KB Output isn't correct
33 Incorrect 23 ms 26572 KB Output isn't correct
34 Incorrect 11 ms 25804 KB Output isn't correct
35 Incorrect 15 ms 26196 KB Output isn't correct
36 Incorrect 46 ms 28176 KB Output isn't correct
37 Incorrect 10 ms 25556 KB Output isn't correct
38 Execution timed out 1079 ms 103656 KB Time limit exceeded
39 Incorrect 11 ms 25556 KB Output isn't correct
40 Incorrect 165 ms 35472 KB Output isn't correct
41 Incorrect 15 ms 25556 KB Output isn't correct
42 Incorrect 15 ms 25684 KB Output isn't correct
43 Execution timed out 1088 ms 103572 KB Time limit exceeded
44 Incorrect 39 ms 27084 KB Output isn't correct
45 Incorrect 996 ms 70756 KB Output isn't correct
46 Correct 826 ms 70856 KB Output is correct
47 Incorrect 977 ms 70788 KB Output isn't correct
48 Incorrect 851 ms 70828 KB Output isn't correct
49 Execution timed out 1084 ms 103664 KB Time limit exceeded
50 Incorrect 881 ms 70808 KB Output isn't correct
51 Incorrect 877 ms 70840 KB Output isn't correct
52 Incorrect 865 ms 70824 KB Output isn't correct
53 Incorrect 843 ms 70764 KB Output isn't correct
54 Correct 484 ms 54372 KB Output is correct
55 Incorrect 452 ms 54388 KB Output isn't correct
56 Execution timed out 1073 ms 103648 KB Time limit exceeded
57 Incorrect 439 ms 54332 KB Output isn't correct
58 Correct 457 ms 54356 KB Output is correct
59 Incorrect 424 ms 54340 KB Output isn't correct
60 Correct 767 ms 70868 KB Output is correct
61 Execution timed out 1043 ms 103672 KB Time limit exceeded
62 Execution timed out 1083 ms 103668 KB Time limit exceeded
63 Execution timed out 1085 ms 103548 KB Time limit exceeded
64 Correct 437 ms 54460 KB Output is correct
65 Incorrect 798 ms 70824 KB Output isn't correct
66 Incorrect 868 ms 70864 KB Output isn't correct
67 Incorrect 944 ms 70780 KB Output isn't correct
68 Execution timed out 1043 ms 103576 KB Time limit exceeded
69 Incorrect 436 ms 54416 KB Output isn't correct
70 Incorrect 140 ms 37652 KB Output isn't correct
71 Incorrect 286 ms 46220 KB Output isn't correct
72 Incorrect 377 ms 54364 KB Output isn't correct
73 Incorrect 416 ms 54496 KB Output isn't correct
74 Incorrect 387 ms 54356 KB Output isn't correct
75 Incorrect 418 ms 54328 KB Output isn't correct
76 Incorrect 439 ms 54384 KB Output isn't correct
77 Incorrect 458 ms 54332 KB Output isn't correct
78 Incorrect 448 ms 54412 KB Output isn't correct
79 Incorrect 130 ms 38132 KB Output isn't correct
80 Incorrect 116 ms 38128 KB Output isn't correct
81 Incorrect 148 ms 40036 KB Output isn't correct
82 Incorrect 500 ms 54416 KB Output isn't correct
83 Incorrect 535 ms 54432 KB Output isn't correct
84 Incorrect 120 ms 38040 KB Output isn't correct
85 Incorrect 462 ms 54316 KB Output isn't correct
86 Execution timed out 1067 ms 103560 KB Time limit exceeded
87 Incorrect 403 ms 54328 KB Output isn't correct
88 Incorrect 470 ms 54436 KB Output isn't correct
89 Incorrect 668 ms 70776 KB Output isn't correct
90 Incorrect 238 ms 41792 KB Output isn't correct
91 Incorrect 532 ms 70824 KB Output isn't correct
92 Incorrect 678 ms 70808 KB Output isn't correct
93 Execution timed out 1088 ms 103648 KB Time limit exceeded
94 Incorrect 687 ms 70852 KB Output isn't correct
95 Incorrect 486 ms 54344 KB Output isn't correct
96 Incorrect 483 ms 54416 KB Output isn't correct
97 Execution timed out 1090 ms 103600 KB Time limit exceeded
98 Incorrect 492 ms 54352 KB Output isn't correct
99 Incorrect 647 ms 70832 KB Output isn't correct
100 Execution timed out 1106 ms 103640 KB Time limit exceeded