# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
399962 |
2021-05-07T01:43:48 Z |
abc864197532 |
Bomb (IZhO17_bomb) |
C++17 |
|
192 ms |
7916 KB |
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair <int, int>
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define info() cerr << __PRETTY_FUNCTION__ << ": " << __LINE__ << endl
#define test(args...) info(), abc("[" + string(#args) + "]", args)
void abc() {cerr << endl;}
template <typename T, typename ...U> void abc(T a, U ...b) {
cerr << a << ' ', abc(b...);
}
template <typename T> void printv(T l, T r) {
while (l != r) cout << *l << " \n"[++l == r];
}
template <typename A, typename B> istream& operator >> (istream& o, pair<A, B> &a) {
return o >> a.X >> a.Y;
}
template <typename A, typename B> ostream& operator << (ostream& o, pair<A, B> a) {
return o << '(' << a.X << ", " << a.Y << ')';
}
template <typename T> ostream& operator << (ostream& o, vector<T> a) {
bool is = false;
for (T i : a) {o << (is ? ' ' : '{'), is = true, o << i;}
return o << '}';
}
const int N = 1000087, logN = 20, K = 111;
int main () {
ios::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
string s[n];
for (int i = 0; i < n; ++i) cin >> s[i];
vector <int> cnt(m, 0), len(n + 1, 1 << 30);
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
cnt[j] = s[i][j] == '0' ? 0 : cnt[j] + 1;
}
vector <int> l(m), r(m);
stack <int> stk;
for (int j = 0; j < m; ++j) {
if (!stk.empty() && cnt[stk.top()] >= cnt[j]) stk.pop();
l[j] = stk.empty() ? j + 1 : j - stk.top();
stk.push(j);
}
while (!stk.empty()) stk.pop();
for (int j = m - 1; ~j; --j) {
if (!stk.empty() && cnt[stk.top()] >= cnt[j]) stk.pop();
r[j] = stk.empty() ? m - j : stk.top() - j;
stk.push(j);
}
for (int j = 0; j < m; ++j) if (cnt[j] > 0) {
len[cnt[j]] = min(len[cnt[j]], l[j] + r[j] - 1);
}
}
int mn = m + 1;
for (int j = 0; j < m; ++j) {
int now = 0;
for (int i = 0; i < n; ++i) {
if (s[i][j] == '0') {
if (now > 0) mn = min(mn, now);
now = 0;
}
else now++;
}
if (now > 0) mn = min(mn, now);
}
if (mn == m + 1) mn = 0;
int ans = 0;
for (int i = 1; i <= mn; ++i) ans = max(ans, len[i] * i);
cout << ans << endl;
}
/*
5 6
001000
111110
111110
111110
000100
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
320 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Incorrect |
1 ms |
328 KB |
Output isn't correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
14 |
Correct |
1 ms |
320 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Incorrect |
1 ms |
324 KB |
Output isn't correct |
18 |
Correct |
1 ms |
320 KB |
Output is correct |
19 |
Incorrect |
1 ms |
320 KB |
Output isn't correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
23 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
24 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
25 |
Correct |
2 ms |
332 KB |
Output is correct |
26 |
Incorrect |
2 ms |
332 KB |
Output isn't correct |
27 |
Correct |
3 ms |
564 KB |
Output is correct |
28 |
Incorrect |
3 ms |
460 KB |
Output isn't correct |
29 |
Correct |
4 ms |
460 KB |
Output is correct |
30 |
Incorrect |
5 ms |
712 KB |
Output isn't correct |
31 |
Incorrect |
5 ms |
588 KB |
Output isn't correct |
32 |
Incorrect |
4 ms |
588 KB |
Output isn't correct |
33 |
Correct |
5 ms |
716 KB |
Output is correct |
34 |
Incorrect |
3 ms |
460 KB |
Output isn't correct |
35 |
Incorrect |
5 ms |
712 KB |
Output isn't correct |
36 |
Incorrect |
6 ms |
716 KB |
Output isn't correct |
37 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
38 |
Correct |
169 ms |
7828 KB |
Output is correct |
39 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
40 |
Correct |
21 ms |
1484 KB |
Output is correct |
41 |
Correct |
1 ms |
204 KB |
Output is correct |
42 |
Correct |
1 ms |
332 KB |
Output is correct |
43 |
Incorrect |
167 ms |
7756 KB |
Output isn't correct |
44 |
Correct |
5 ms |
716 KB |
Output is correct |
45 |
Incorrect |
167 ms |
7832 KB |
Output isn't correct |
46 |
Correct |
174 ms |
7844 KB |
Output is correct |
47 |
Incorrect |
163 ms |
7752 KB |
Output isn't correct |
48 |
Incorrect |
160 ms |
7740 KB |
Output isn't correct |
49 |
Incorrect |
192 ms |
7752 KB |
Output isn't correct |
50 |
Incorrect |
163 ms |
7840 KB |
Output isn't correct |
51 |
Incorrect |
160 ms |
7744 KB |
Output isn't correct |
52 |
Incorrect |
161 ms |
7832 KB |
Output isn't correct |
53 |
Incorrect |
190 ms |
7892 KB |
Output isn't correct |
54 |
Incorrect |
153 ms |
7756 KB |
Output isn't correct |
55 |
Incorrect |
153 ms |
7756 KB |
Output isn't correct |
56 |
Correct |
185 ms |
7828 KB |
Output is correct |
57 |
Incorrect |
160 ms |
7748 KB |
Output isn't correct |
58 |
Incorrect |
154 ms |
7768 KB |
Output isn't correct |
59 |
Incorrect |
153 ms |
7756 KB |
Output isn't correct |
60 |
Incorrect |
158 ms |
7844 KB |
Output isn't correct |
61 |
Incorrect |
172 ms |
7832 KB |
Output isn't correct |
62 |
Incorrect |
168 ms |
7840 KB |
Output isn't correct |
63 |
Incorrect |
166 ms |
7836 KB |
Output isn't correct |
64 |
Incorrect |
154 ms |
7836 KB |
Output isn't correct |
65 |
Incorrect |
173 ms |
7828 KB |
Output isn't correct |
66 |
Incorrect |
160 ms |
7832 KB |
Output isn't correct |
67 |
Incorrect |
167 ms |
7756 KB |
Output isn't correct |
68 |
Incorrect |
185 ms |
7876 KB |
Output isn't correct |
69 |
Incorrect |
157 ms |
7804 KB |
Output isn't correct |
70 |
Incorrect |
83 ms |
5352 KB |
Output isn't correct |
71 |
Incorrect |
151 ms |
7844 KB |
Output isn't correct |
72 |
Correct |
158 ms |
7836 KB |
Output is correct |
73 |
Incorrect |
155 ms |
7828 KB |
Output isn't correct |
74 |
Incorrect |
156 ms |
7876 KB |
Output isn't correct |
75 |
Incorrect |
155 ms |
7756 KB |
Output isn't correct |
76 |
Correct |
165 ms |
7836 KB |
Output is correct |
77 |
Correct |
166 ms |
7832 KB |
Output is correct |
78 |
Correct |
155 ms |
7800 KB |
Output is correct |
79 |
Incorrect |
152 ms |
7752 KB |
Output isn't correct |
80 |
Incorrect |
152 ms |
7816 KB |
Output isn't correct |
81 |
Incorrect |
152 ms |
7832 KB |
Output isn't correct |
82 |
Correct |
154 ms |
7916 KB |
Output is correct |
83 |
Incorrect |
179 ms |
7828 KB |
Output isn't correct |
84 |
Incorrect |
163 ms |
7868 KB |
Output isn't correct |
85 |
Incorrect |
158 ms |
7876 KB |
Output isn't correct |
86 |
Incorrect |
181 ms |
7832 KB |
Output isn't correct |
87 |
Correct |
155 ms |
7728 KB |
Output is correct |
88 |
Incorrect |
156 ms |
7872 KB |
Output isn't correct |
89 |
Incorrect |
156 ms |
7876 KB |
Output isn't correct |
90 |
Incorrect |
83 ms |
5324 KB |
Output isn't correct |
91 |
Correct |
158 ms |
7748 KB |
Output is correct |
92 |
Correct |
153 ms |
7832 KB |
Output is correct |
93 |
Correct |
171 ms |
7780 KB |
Output is correct |
94 |
Incorrect |
156 ms |
7832 KB |
Output isn't correct |
95 |
Incorrect |
157 ms |
7832 KB |
Output isn't correct |
96 |
Incorrect |
165 ms |
7832 KB |
Output isn't correct |
97 |
Correct |
165 ms |
7824 KB |
Output is correct |
98 |
Correct |
149 ms |
7844 KB |
Output is correct |
99 |
Incorrect |
156 ms |
7876 KB |
Output isn't correct |
100 |
Incorrect |
172 ms |
7832 KB |
Output isn't correct |