# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
108948 |
2019-05-03T07:14:07 Z |
ihdignite |
Bomb (IZhO17_bomb) |
C++14 |
|
1000 ms |
132096 KB |
#include <bits/stdc++.h>
using namespace std;
const int mxN=2500;
int n, m, mc=1e9, ans, p[mxN*mxN], s[mxN*mxN];
string g[mxN];
vector<array<int, 2>> ta[mxN+1];
priority_queue<int, vector<int>, greater<int>> pq1, pq2;
int find(int x) {
return x==p[x]?x:(p[x]=find(p[x]));
}
void join(int x, int y) {
if((x=find(x))==(y=find(y)))
return;
if(s[x]<s[y])
swap(x, y);
p[y]=x;
pq2.push(s[x]);
pq2.push(s[y]);
s[x]+=s[y];
pq1.push(s[x]);
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for(int i=0; i<n; ++i) {
cin >> g[i];
for(int j=0, l=0; j<m; ++j) {
l=g[i][j]&1?1+l:0;
ta[l].push_back({i, j});
if(l&&(j+1>=m||g[i][j+1]&1^1))
mc=min(l, mc);
}
}
assert(mc<1e9);
iota(p, p+n*m, 0);
for(int i=m; i; --i) {
for(array<int, 2> a : ta[i]) {
pq1.push(s[a[0]*m+a[1]]=1);
if(a[0]&&s[a[0]*m-m+a[1]])
join(a[0]*m+a[1], a[0]*m-m+a[1]);
if(a[0]<n-1&&s[a[0]*m+m+a[1]])
join(a[0]*m+a[1], a[0]*m+m+a[1]);
}
while(pq1.size()&&pq2.size()&&pq1.top()==pq2.top()) {
pq1.pop();
pq2.pop();
}
if(i<=mc)
ans=max(i*pq1.top(), ans);
}
cout << ans;
}
Compilation message
bomb.cpp: In function 'int main()':
bomb.cpp:36:28: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
if(l&&(j+1>=m||g[i][j+1]&1^1))
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
3 ms |
640 KB |
Output is correct |
4 |
Correct |
3 ms |
640 KB |
Output is correct |
5 |
Correct |
3 ms |
640 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
2 ms |
512 KB |
Output is correct |
8 |
Incorrect |
2 ms |
512 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
512 KB |
Output isn't correct |
10 |
Correct |
2 ms |
512 KB |
Output is correct |
11 |
Incorrect |
2 ms |
512 KB |
Output isn't correct |
12 |
Correct |
2 ms |
512 KB |
Output is correct |
13 |
Correct |
2 ms |
512 KB |
Output is correct |
14 |
Correct |
2 ms |
512 KB |
Output is correct |
15 |
Incorrect |
2 ms |
512 KB |
Output isn't correct |
16 |
Correct |
3 ms |
512 KB |
Output is correct |
17 |
Incorrect |
3 ms |
640 KB |
Output isn't correct |
18 |
Correct |
3 ms |
640 KB |
Output is correct |
19 |
Incorrect |
3 ms |
640 KB |
Output isn't correct |
20 |
Incorrect |
3 ms |
640 KB |
Output isn't correct |
21 |
Correct |
3 ms |
640 KB |
Output is correct |
22 |
Correct |
2 ms |
640 KB |
Output is correct |
23 |
Incorrect |
3 ms |
768 KB |
Output isn't correct |
24 |
Incorrect |
2 ms |
640 KB |
Output isn't correct |
25 |
Incorrect |
3 ms |
640 KB |
Output isn't correct |
26 |
Correct |
6 ms |
896 KB |
Output is correct |
27 |
Correct |
29 ms |
3180 KB |
Output is correct |
28 |
Correct |
14 ms |
2192 KB |
Output is correct |
29 |
Correct |
32 ms |
3700 KB |
Output is correct |
30 |
Incorrect |
24 ms |
4432 KB |
Output isn't correct |
31 |
Incorrect |
17 ms |
3400 KB |
Output isn't correct |
32 |
Incorrect |
16 ms |
3492 KB |
Output isn't correct |
33 |
Incorrect |
35 ms |
4936 KB |
Output isn't correct |
34 |
Correct |
5 ms |
1812 KB |
Output is correct |
35 |
Incorrect |
12 ms |
3544 KB |
Output isn't correct |
36 |
Incorrect |
81 ms |
6144 KB |
Output isn't correct |
37 |
Incorrect |
2 ms |
512 KB |
Output isn't correct |
38 |
Execution timed out |
1080 ms |
119356 KB |
Time limit exceeded |
39 |
Incorrect |
2 ms |
512 KB |
Output isn't correct |
40 |
Incorrect |
355 ms |
20180 KB |
Output isn't correct |
41 |
Incorrect |
3 ms |
512 KB |
Output isn't correct |
42 |
Incorrect |
5 ms |
640 KB |
Output isn't correct |
43 |
Execution timed out |
1087 ms |
132096 KB |
Time limit exceeded |
44 |
Incorrect |
60 ms |
4716 KB |
Output isn't correct |
45 |
Execution timed out |
1095 ms |
121368 KB |
Time limit exceeded |
46 |
Execution timed out |
1078 ms |
109844 KB |
Time limit exceeded |
47 |
Execution timed out |
1093 ms |
119704 KB |
Time limit exceeded |
48 |
Runtime error |
749 ms |
132096 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
49 |
Runtime error |
1000 ms |
132096 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
50 |
Runtime error |
710 ms |
132096 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
51 |
Runtime error |
666 ms |
132096 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
52 |
Runtime error |
716 ms |
132096 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
53 |
Runtime error |
699 ms |
132096 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
54 |
Correct |
879 ms |
110868 KB |
Output is correct |
55 |
Correct |
844 ms |
109276 KB |
Output is correct |
56 |
Execution timed out |
1090 ms |
108044 KB |
Time limit exceeded |
57 |
Correct |
844 ms |
106152 KB |
Output is correct |
58 |
Correct |
852 ms |
126816 KB |
Output is correct |
59 |
Correct |
822 ms |
106116 KB |
Output is correct |
60 |
Runtime error |
982 ms |
132096 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
61 |
Execution timed out |
1070 ms |
125108 KB |
Time limit exceeded |
62 |
Execution timed out |
1077 ms |
132096 KB |
Time limit exceeded |
63 |
Execution timed out |
1085 ms |
120696 KB |
Time limit exceeded |
64 |
Correct |
670 ms |
118584 KB |
Output is correct |
65 |
Runtime error |
815 ms |
132096 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
66 |
Runtime error |
814 ms |
132096 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
67 |
Runtime error |
712 ms |
132096 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
68 |
Runtime error |
657 ms |
132096 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
69 |
Correct |
920 ms |
106536 KB |
Output is correct |
70 |
Incorrect |
310 ms |
61144 KB |
Output isn't correct |
71 |
Incorrect |
837 ms |
105768 KB |
Output isn't correct |
72 |
Execution timed out |
1035 ms |
114800 KB |
Time limit exceeded |
73 |
Execution timed out |
1064 ms |
119604 KB |
Time limit exceeded |
74 |
Execution timed out |
1082 ms |
115484 KB |
Time limit exceeded |
75 |
Execution timed out |
1056 ms |
124184 KB |
Time limit exceeded |
76 |
Execution timed out |
1079 ms |
125524 KB |
Time limit exceeded |
77 |
Execution timed out |
1085 ms |
124628 KB |
Time limit exceeded |
78 |
Execution timed out |
1084 ms |
125140 KB |
Time limit exceeded |
79 |
Incorrect |
188 ms |
83768 KB |
Output isn't correct |
80 |
Incorrect |
199 ms |
84124 KB |
Output isn't correct |
81 |
Incorrect |
262 ms |
87420 KB |
Output isn't correct |
82 |
Execution timed out |
1073 ms |
126908 KB |
Time limit exceeded |
83 |
Execution timed out |
1072 ms |
127208 KB |
Time limit exceeded |
84 |
Incorrect |
269 ms |
81140 KB |
Output isn't correct |
85 |
Execution timed out |
1052 ms |
128724 KB |
Time limit exceeded |
86 |
Execution timed out |
1087 ms |
118080 KB |
Time limit exceeded |
87 |
Execution timed out |
1049 ms |
126876 KB |
Time limit exceeded |
88 |
Execution timed out |
1068 ms |
125788 KB |
Time limit exceeded |
89 |
Execution timed out |
1054 ms |
106636 KB |
Time limit exceeded |
90 |
Incorrect |
689 ms |
75592 KB |
Output isn't correct |
91 |
Execution timed out |
1081 ms |
132096 KB |
Time limit exceeded |
92 |
Execution timed out |
1083 ms |
118188 KB |
Time limit exceeded |
93 |
Execution timed out |
1058 ms |
119236 KB |
Time limit exceeded |
94 |
Execution timed out |
1064 ms |
116268 KB |
Time limit exceeded |
95 |
Execution timed out |
1067 ms |
126800 KB |
Time limit exceeded |
96 |
Execution timed out |
1075 ms |
126844 KB |
Time limit exceeded |
97 |
Execution timed out |
1076 ms |
119604 KB |
Time limit exceeded |
98 |
Execution timed out |
1073 ms |
126088 KB |
Time limit exceeded |
99 |
Execution timed out |
1075 ms |
118476 KB |
Time limit exceeded |
100 |
Execution timed out |
1061 ms |
119284 KB |
Time limit exceeded |