Submission #108947

# Submission time Handle Problem Language Result Execution time Memory
108947 2019-05-03T07:11:00 Z ihdignite Bomb (IZhO17_bomb) C++14
28 / 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=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 3 ms 512 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 4 ms 640 KB Output is correct
4 Correct 4 ms 640 KB Output is correct
5 Correct 3 ms 640 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 3 ms 512 KB Output is correct
8 Incorrect 9 ms 512 KB Output isn't correct
9 Incorrect 3 ms 512 KB Output isn't correct
10 Correct 2 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 3 ms 512 KB Output is correct
17 Incorrect 4 ms 640 KB Output isn't correct
18 Correct 3 ms 632 KB Output is correct
19 Incorrect 4 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 3 ms 640 KB Output is correct
23 Incorrect 4 ms 640 KB Output isn't correct
24 Incorrect 3 ms 640 KB Output isn't correct
25 Incorrect 5 ms 696 KB Output isn't correct
26 Correct 7 ms 896 KB Output is correct
27 Correct 30 ms 3152 KB Output is correct
28 Correct 7 ms 2192 KB Output is correct
29 Correct 49 ms 3832 KB Output is correct
30 Incorrect 24 ms 4548 KB Output isn't correct
31 Incorrect 16 ms 3400 KB Output isn't correct
32 Incorrect 14 ms 3492 KB Output isn't correct
33 Incorrect 32 ms 4908 KB Output isn't correct
34 Correct 5 ms 1684 KB Output is correct
35 Incorrect 11 ms 3416 KB Output isn't correct
36 Incorrect 75 ms 6160 KB Output isn't correct
37 Incorrect 3 ms 512 KB Output isn't correct
38 Execution timed out 1064 ms 119596 KB Time limit exceeded
39 Incorrect 4 ms 512 KB Output isn't correct
40 Incorrect 368 ms 20820 KB Output isn't correct
41 Incorrect 2 ms 512 KB Output isn't correct
42 Incorrect 4 ms 768 KB Output isn't correct
43 Execution timed out 1065 ms 127684 KB Time limit exceeded
44 Incorrect 61 ms 4568 KB Output isn't correct
45 Execution timed out 1074 ms 121420 KB Time limit exceeded
46 Execution timed out 1079 ms 110880 KB Time limit exceeded
47 Execution timed out 1094 ms 121880 KB Time limit exceeded
48 Runtime error 711 ms 132096 KB Execution killed with signal 9 (could be triggered by violating memory limits)
49 Runtime error 997 ms 132096 KB Execution killed with signal 9 (could be triggered by violating memory limits)
50 Runtime error 836 ms 132096 KB Execution killed with signal 9 (could be triggered by violating memory limits)
51 Runtime error 736 ms 132096 KB Execution killed with signal 9 (could be triggered by violating memory limits)
52 Runtime error 754 ms 132096 KB Execution killed with signal 9 (could be triggered by violating memory limits)
53 Runtime error 685 ms 132096 KB Execution killed with signal 9 (could be triggered by violating memory limits)
54 Correct 853 ms 111704 KB Output is correct
55 Correct 874 ms 110108 KB Output is correct
56 Execution timed out 1077 ms 108900 KB Time limit exceeded
57 Correct 912 ms 106964 KB Output is correct
58 Correct 872 ms 128444 KB Output is correct
59 Correct 772 ms 106916 KB Output is correct
60 Runtime error 818 ms 132096 KB Execution killed with signal 9 (could be triggered by violating memory limits)
61 Execution timed out 1085 ms 122708 KB Time limit exceeded
62 Execution timed out 1084 ms 132096 KB Time limit exceeded
63 Execution timed out 1083 ms 120568 KB Time limit exceeded
64 Correct 659 ms 119376 KB Output is correct
65 Runtime error 770 ms 132096 KB Execution killed with signal 9 (could be triggered by violating memory limits)
66 Runtime error 761 ms 132096 KB Execution killed with signal 9 (could be triggered by violating memory limits)
67 Runtime error 790 ms 132096 KB Execution killed with signal 9 (could be triggered by violating memory limits)
68 Runtime error 630 ms 132096 KB Execution killed with signal 9 (could be triggered by violating memory limits)
69 Correct 742 ms 107324 KB Output is correct
70 Incorrect 294 ms 61812 KB Output isn't correct
71 Incorrect 673 ms 106628 KB Output isn't correct
72 Incorrect 966 ms 115464 KB Output isn't correct
73 Execution timed out 1059 ms 120148 KB Time limit exceeded
74 Execution timed out 1036 ms 116436 KB Time limit exceeded
75 Execution timed out 1075 ms 124756 KB Time limit exceeded
76 Execution timed out 1078 ms 126060 KB Time limit exceeded
77 Execution timed out 1091 ms 125436 KB Time limit exceeded
78 Execution timed out 1089 ms 125880 KB Time limit exceeded
79 Incorrect 221 ms 84332 KB Output isn't correct
80 Incorrect 228 ms 84712 KB Output isn't correct
81 Incorrect 309 ms 88228 KB Output isn't correct
82 Execution timed out 1089 ms 128056 KB Time limit exceeded
83 Execution timed out 1087 ms 128456 KB Time limit exceeded
84 Incorrect 207 ms 81656 KB Output isn't correct
85 Execution timed out 1089 ms 131784 KB Time limit exceeded
86 Execution timed out 1086 ms 120300 KB Time limit exceeded
87 Correct 958 ms 128340 KB Output is correct
88 Execution timed out 1082 ms 126240 KB Time limit exceeded
89 Execution timed out 1070 ms 119352 KB Time limit exceeded
90 Incorrect 726 ms 75888 KB Output isn't correct
91 Execution timed out 1073 ms 132096 KB Time limit exceeded
92 Execution timed out 1078 ms 120484 KB Time limit exceeded
93 Execution timed out 1083 ms 121588 KB Time limit exceeded
94 Execution timed out 1085 ms 130444 KB Time limit exceeded
95 Execution timed out 1075 ms 128504 KB Time limit exceeded
96 Execution timed out 1091 ms 128232 KB Time limit exceeded
97 Execution timed out 1048 ms 118248 KB Time limit exceeded
98 Execution timed out 1055 ms 126688 KB Time limit exceeded
99 Execution timed out 1081 ms 132096 KB Time limit exceeded
100 Execution timed out 1080 ms 120764 KB Time limit exceeded