Submission #108946

# Submission time Handle Problem Language Result Execution time Memory
108946 2019-05-03T05:25:47 Z ihdignite Bomb (IZhO17_bomb) C++14
23 / 100
1000 ms 132096 KB
#include <bits/stdc++.h>
using namespace std;

const int mxN=2500;
int n, m, mc=mxN, 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);
		}
	}
	iota(p, p+n*m, 0);
	for(int i=n; 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 Incorrect 2 ms 512 KB Output isn't 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 Incorrect 3 ms 632 KB Output isn't correct
6 Incorrect 2 ms 512 KB Output isn't correct
7 Correct 2 ms 512 KB Output is correct
8 Incorrect 5 ms 512 KB Output isn't correct
9 Incorrect 2 ms 512 KB Output isn't correct
10 Correct 3 ms 512 KB Output is correct
11 Incorrect 3 ms 512 KB Output isn't correct
12 Correct 3 ms 512 KB Output is correct
13 Correct 3 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 2 ms 564 KB Output is correct
17 Incorrect 2 ms 640 KB Output isn't correct
18 Correct 4 ms 640 KB Output is correct
19 Incorrect 3 ms 640 KB Output isn't correct
20 Incorrect 2 ms 640 KB Output isn't correct
21 Correct 3 ms 640 KB Output is correct
22 Correct 3 ms 640 KB Output is correct
23 Incorrect 4 ms 768 KB Output isn't correct
24 Incorrect 4 ms 640 KB Output isn't correct
25 Incorrect 4 ms 768 KB Output isn't correct
26 Correct 7 ms 768 KB Output is correct
27 Correct 24 ms 3064 KB Output is correct
28 Correct 6 ms 2164 KB Output is correct
29 Correct 38 ms 3708 KB Output is correct
30 Incorrect 23 ms 4560 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 34 ms 4944 KB Output isn't correct
34 Correct 5 ms 1812 KB Output is correct
35 Incorrect 11 ms 3416 KB Output isn't correct
36 Incorrect 82 ms 6064 KB Output isn't correct
37 Incorrect 3 ms 512 KB Output isn't correct
38 Execution timed out 1084 ms 125980 KB Time limit exceeded
39 Incorrect 2 ms 512 KB Output isn't correct
40 Incorrect 198 ms 23348 KB Output isn't correct
41 Incorrect 4 ms 512 KB Output isn't correct
42 Incorrect 5 ms 640 KB Output isn't correct
43 Execution timed out 1090 ms 132096 KB Time limit exceeded
44 Incorrect 60 ms 4596 KB Output isn't correct
45 Execution timed out 1080 ms 126164 KB Time limit exceeded
46 Execution timed out 1071 ms 115988 KB Time limit exceeded
47 Execution timed out 1082 ms 125956 KB Time limit exceeded
48 Runtime error 794 ms 132096 KB Execution killed with signal 9 (could be triggered by violating memory limits)
49 Runtime error 851 ms 132096 KB Execution killed with signal 9 (could be triggered by violating memory limits)
50 Runtime error 687 ms 132096 KB Execution killed with signal 9 (could be triggered by violating memory limits)
51 Runtime error 687 ms 132096 KB Execution killed with signal 9 (could be triggered by violating memory limits)
52 Runtime error 678 ms 132096 KB Execution killed with signal 9 (could be triggered by violating memory limits)
53 Runtime error 875 ms 132096 KB Execution killed with signal 9 (could be triggered by violating memory limits)
54 Correct 878 ms 116948 KB Output is correct
55 Correct 910 ms 115260 KB Output is correct
56 Execution timed out 1048 ms 114008 KB Time limit exceeded
57 Correct 780 ms 112084 KB Output is correct
58 Runtime error 888 ms 132096 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
59 Correct 791 ms 112036 KB Output is correct
60 Runtime error 881 ms 132096 KB Execution killed with signal 9 (could be triggered by violating memory limits)
61 Execution timed out 1080 ms 132096 KB Time limit exceeded
62 Execution timed out 1077 ms 132096 KB Time limit exceeded
63 Execution timed out 1082 ms 126708 KB Time limit exceeded
64 Correct 640 ms 124544 KB Output is correct
65 Runtime error 683 ms 132096 KB Execution killed with signal 9 (could be triggered by violating memory limits)
66 Runtime error 732 ms 132096 KB Execution killed with signal 9 (could be triggered by violating memory limits)
67 Runtime error 724 ms 132096 KB Execution killed with signal 9 (could be triggered by violating memory limits)
68 Runtime error 686 ms 132096 KB Execution killed with signal 9 (could be triggered by violating memory limits)
69 Correct 712 ms 112444 KB Output is correct
70 Incorrect 296 ms 64832 KB Output isn't correct
71 Incorrect 744 ms 111932 KB Output isn't correct
72 Incorrect 977 ms 120756 KB Output isn't correct
73 Execution timed out 1068 ms 125524 KB Time limit exceeded
74 Execution timed out 1048 ms 121660 KB Time limit exceeded
75 Execution timed out 1085 ms 130276 KB Time limit exceeded
76 Execution timed out 1088 ms 131564 KB Time limit exceeded
77 Execution timed out 1092 ms 130644 KB Time limit exceeded
78 Execution timed out 1070 ms 131436 KB Time limit exceeded
79 Incorrect 193 ms 89708 KB Output isn't correct
80 Incorrect 202 ms 90212 KB Output isn't correct
81 Incorrect 256 ms 93352 KB Output isn't correct
82 Execution timed out 1074 ms 132096 KB Time limit exceeded
83 Execution timed out 1082 ms 132096 KB Time limit exceeded
84 Incorrect 199 ms 87160 KB Output isn't correct
85 Execution timed out 1089 ms 132096 KB Time limit exceeded
86 Execution timed out 1090 ms 125392 KB Time limit exceeded
87 Execution timed out 1073 ms 132096 KB Time limit exceeded
88 Execution timed out 1063 ms 131832 KB Time limit exceeded
89 Execution timed out 1066 ms 132096 KB Time limit exceeded
90 Incorrect 651 ms 79312 KB Output isn't correct
91 Execution timed out 1096 ms 132096 KB Time limit exceeded
92 Execution timed out 1089 ms 125380 KB Time limit exceeded
93 Execution timed out 1070 ms 125156 KB Time limit exceeded
94 Execution timed out 1093 ms 132096 KB Time limit exceeded
95 Execution timed out 1083 ms 132096 KB Time limit exceeded
96 Execution timed out 1085 ms 132096 KB Time limit exceeded
97 Execution timed out 1079 ms 126824 KB Time limit exceeded
98 Execution timed out 1075 ms 132096 KB Time limit exceeded
99 Execution timed out 1084 ms 132096 KB Time limit exceeded
100 Execution timed out 1085 ms 125812 KB Time limit exceeded