# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
655812 |
2022-11-05T15:45:39 Z |
someone |
Bomb (IZhO17_bomb) |
C++14 |
|
1000 ms |
103792 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(!alien[id+1])
minLen = min(minLen, t[j]);
} else {
t[j] = 0;
}
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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
25684 KB |
Output is correct |
2 |
Incorrect |
12 ms |
25740 KB |
Output isn't correct |
3 |
Incorrect |
11 ms |
25684 KB |
Output isn't correct |
4 |
Incorrect |
12 ms |
25684 KB |
Output isn't correct |
5 |
Correct |
12 ms |
25752 KB |
Output is correct |
6 |
Correct |
11 ms |
25568 KB |
Output is correct |
7 |
Correct |
11 ms |
25556 KB |
Output is correct |
8 |
Incorrect |
11 ms |
25556 KB |
Output isn't correct |
9 |
Correct |
12 ms |
25628 KB |
Output is correct |
10 |
Correct |
11 ms |
25568 KB |
Output is correct |
11 |
Incorrect |
11 ms |
25624 KB |
Output isn't correct |
12 |
Correct |
11 ms |
25568 KB |
Output is correct |
13 |
Correct |
11 ms |
25556 KB |
Output is correct |
14 |
Correct |
11 ms |
25508 KB |
Output is correct |
15 |
Incorrect |
11 ms |
25544 KB |
Output isn't correct |
16 |
Correct |
14 ms |
25556 KB |
Output is correct |
17 |
Incorrect |
11 ms |
25556 KB |
Output isn't correct |
18 |
Correct |
11 ms |
25556 KB |
Output is correct |
19 |
Incorrect |
12 ms |
25588 KB |
Output isn't correct |
20 |
Incorrect |
12 ms |
25628 KB |
Output isn't correct |
21 |
Correct |
11 ms |
25560 KB |
Output is correct |
22 |
Correct |
14 ms |
25556 KB |
Output is correct |
23 |
Incorrect |
12 ms |
25684 KB |
Output isn't correct |
24 |
Incorrect |
13 ms |
25628 KB |
Output isn't correct |
25 |
Incorrect |
12 ms |
25624 KB |
Output isn't correct |
26 |
Correct |
13 ms |
25760 KB |
Output is correct |
27 |
Correct |
42 ms |
26872 KB |
Output is correct |
28 |
Correct |
13 ms |
25804 KB |
Output is correct |
29 |
Correct |
33 ms |
27044 KB |
Output is correct |
30 |
Incorrect |
20 ms |
26576 KB |
Output isn't correct |
31 |
Incorrect |
16 ms |
26276 KB |
Output isn't correct |
32 |
Incorrect |
17 ms |
26244 KB |
Output isn't correct |
33 |
Incorrect |
26 ms |
26564 KB |
Output isn't correct |
34 |
Correct |
13 ms |
25684 KB |
Output is correct |
35 |
Incorrect |
15 ms |
26196 KB |
Output isn't correct |
36 |
Incorrect |
52 ms |
28192 KB |
Output isn't correct |
37 |
Incorrect |
13 ms |
25556 KB |
Output isn't correct |
38 |
Execution timed out |
1083 ms |
103648 KB |
Time limit exceeded |
39 |
Incorrect |
12 ms |
25520 KB |
Output isn't correct |
40 |
Incorrect |
167 ms |
35424 KB |
Output isn't correct |
41 |
Incorrect |
11 ms |
25564 KB |
Output isn't correct |
42 |
Incorrect |
12 ms |
25704 KB |
Output isn't correct |
43 |
Execution timed out |
1077 ms |
103648 KB |
Time limit exceeded |
44 |
Incorrect |
38 ms |
27084 KB |
Output isn't correct |
45 |
Incorrect |
977 ms |
70920 KB |
Output isn't correct |
46 |
Correct |
964 ms |
70756 KB |
Output is correct |
47 |
Execution timed out |
1016 ms |
70700 KB |
Time limit exceeded |
48 |
Incorrect |
905 ms |
70708 KB |
Output isn't correct |
49 |
Execution timed out |
1075 ms |
103760 KB |
Time limit exceeded |
50 |
Incorrect |
933 ms |
70816 KB |
Output isn't correct |
51 |
Incorrect |
927 ms |
70840 KB |
Output isn't correct |
52 |
Incorrect |
899 ms |
70720 KB |
Output isn't correct |
53 |
Incorrect |
895 ms |
70820 KB |
Output isn't correct |
54 |
Correct |
490 ms |
54420 KB |
Output is correct |
55 |
Correct |
474 ms |
54352 KB |
Output is correct |
56 |
Execution timed out |
1035 ms |
103792 KB |
Time limit exceeded |
57 |
Correct |
439 ms |
54392 KB |
Output is correct |
58 |
Correct |
486 ms |
54304 KB |
Output is correct |
59 |
Correct |
433 ms |
54332 KB |
Output is correct |
60 |
Correct |
820 ms |
70764 KB |
Output is correct |
61 |
Execution timed out |
1080 ms |
103572 KB |
Time limit exceeded |
62 |
Execution timed out |
1092 ms |
103672 KB |
Time limit exceeded |
63 |
Execution timed out |
1079 ms |
103688 KB |
Time limit exceeded |
64 |
Correct |
478 ms |
54328 KB |
Output is correct |
65 |
Incorrect |
861 ms |
70876 KB |
Output isn't correct |
66 |
Incorrect |
872 ms |
70960 KB |
Output isn't correct |
67 |
Incorrect |
995 ms |
70952 KB |
Output isn't correct |
68 |
Execution timed out |
1072 ms |
103616 KB |
Time limit exceeded |
69 |
Correct |
427 ms |
54424 KB |
Output is correct |
70 |
Incorrect |
155 ms |
37728 KB |
Output isn't correct |
71 |
Incorrect |
327 ms |
46164 KB |
Output isn't correct |
72 |
Incorrect |
443 ms |
54332 KB |
Output isn't correct |
73 |
Incorrect |
460 ms |
54400 KB |
Output isn't correct |
74 |
Incorrect |
451 ms |
54436 KB |
Output isn't correct |
75 |
Incorrect |
477 ms |
54332 KB |
Output isn't correct |
76 |
Incorrect |
476 ms |
54332 KB |
Output isn't correct |
77 |
Incorrect |
497 ms |
54332 KB |
Output isn't correct |
78 |
Incorrect |
491 ms |
54308 KB |
Output isn't correct |
79 |
Incorrect |
120 ms |
38240 KB |
Output isn't correct |
80 |
Incorrect |
120 ms |
38228 KB |
Output isn't correct |
81 |
Incorrect |
142 ms |
40024 KB |
Output isn't correct |
82 |
Incorrect |
554 ms |
54312 KB |
Output isn't correct |
83 |
Incorrect |
521 ms |
54420 KB |
Output isn't correct |
84 |
Incorrect |
123 ms |
38160 KB |
Output isn't correct |
85 |
Incorrect |
486 ms |
54332 KB |
Output isn't correct |
86 |
Execution timed out |
1041 ms |
103652 KB |
Time limit exceeded |
87 |
Incorrect |
459 ms |
54504 KB |
Output isn't correct |
88 |
Incorrect |
539 ms |
54396 KB |
Output isn't correct |
89 |
Incorrect |
715 ms |
70808 KB |
Output isn't correct |
90 |
Incorrect |
256 ms |
41772 KB |
Output isn't correct |
91 |
Incorrect |
583 ms |
70908 KB |
Output isn't correct |
92 |
Incorrect |
710 ms |
70836 KB |
Output isn't correct |
93 |
Execution timed out |
1093 ms |
103600 KB |
Time limit exceeded |
94 |
Incorrect |
715 ms |
70716 KB |
Output isn't correct |
95 |
Incorrect |
523 ms |
54332 KB |
Output isn't correct |
96 |
Incorrect |
547 ms |
54348 KB |
Output isn't correct |
97 |
Execution timed out |
1091 ms |
103608 KB |
Time limit exceeded |
98 |
Incorrect |
538 ms |
54316 KB |
Output isn't correct |
99 |
Incorrect |
733 ms |
70716 KB |
Output isn't correct |
100 |
Execution timed out |
1066 ms |
103604 KB |
Time limit exceeded |