# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
833207 |
2023-08-22T03:12:51 Z |
vjudge1 |
Bomb (IZhO17_bomb) |
C++17 |
|
1000 ms |
74032 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// using ld = long double;
#define all(x) begin(x), end(x)
#ifdef LOCAL
#define debug(...) __VA_ARGS__;
#else
#define debug(...)
#endif
template<class A, class B> ostream& operator<<(ostream& os, const pair<A, B> &p);
template<class T> ostream& operator<<(ostream& os, const vector<T> &v);
template<class T, size_t N> ostream& operator<<(ostream& os, const array<T, N> &v);
template<class A, class B>
ostream& operator<<(ostream& os, const pair<A, B> &p) {
return os << '(' << p.first << ',' << p.second << ')';
}
template<class T>
ostream& operator<<(ostream& os, const vector<T> &v) {
os << '{'; bool fs = 1;
for(auto &i : v) { if(!fs) os << ','; os << i; fs = 0; }
return os << '}';
}
template<class T, size_t N>
ostream& operator<<(ostream& os, const array<T, N> &v) {
os << '{'; bool fs = 1;
for(auto &i : v) { if(!fs) os << ','; os << i; fs = 0; }
return os << '}';
}
void init() {
}
void solve(int tt = 0) {
int n, m; cin >> n >> m;
vector a(n, vector<int>(m));
bool ok = 0;
for(auto &v : a) for(int &i : v) {
char c; cin >> c;
i = c - '0';
ok |= i;
}
if(!ok) return void(cout << 0 << '\n');
int h = 1e9, w = 1e9;
{
vector b = a;
for(int i = 1; i < n; i++) {
for(int j = 0; j < m; j++) {
if(b[i][j] != 0) {
b[i][j] += b[i-1][j];
}
}
}
debug({
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++)
cerr << b[i][j];
cerr << '\n';
}
});
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) if(b[i][j] != 0 && (i == n-1 || (i < n-1 && b[i+1][j] == 0))) {
h = min(h, b[i][j]);
}
}
}
vector pref(n, vector<int>(m));
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
pref[i][j] = a[i][j];
if(i) pref[i][j] += pref[i-1][j];
if(j) pref[i][j] += pref[i][j-1];
if(i > 0 && j > 0) pref[i][j] -= pref[i-1][j-1];
}
}
const auto get = [&](int i1, int j1, int i2, int j2) -> int {
int ans = pref[i2][j2];
if(i1) ans -= pref[i1-1][j2];
if(j1) ans -= pref[i2][j1-1];
if(i1 && j1) ans += pref[i1-1][j1-1];
return ans;
};
int ans = 0;
vector b(n, vector<int>(m));
for(int hh = 1; hh <= h; hh++) {
for(int i = 0; i+hh-1 < n; i++) {
for(int j = 0; j < m; j++) {
b[i][j] = (get(i, j, i+hh-1, j) == hh);
}
}
for(int j = 1; j < m; j++) {
for(int i = 0; i+hh-1 < n; i++) {
b[i][j] += b[i][j-1];
}
}
for(int i = 0; i+hh-1 < n; i++) {
for(int j = 0; j < m; j++) if(b[i][j] != 0 && (j == m-1 || (j < m-1 && b[i][j+1] == 0))) {
ans = max(ans, h * w);
w = min(w, b[i][j]);
}
}
}
cout << ans << '\n';
}
void reset() {
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int t = 1; // cin >> t;
init();
for(int i = 1; i <= t; i++) solve(i), reset();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Correct |
1 ms |
724 KB |
Output is correct |
4 |
Correct |
1 ms |
724 KB |
Output is correct |
5 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
6 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
7 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
8 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
9 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
10 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
11 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
12 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
13 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
14 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
15 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
16 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
17 |
Correct |
1 ms |
464 KB |
Output is correct |
18 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
19 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
20 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
21 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
22 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
23 |
Incorrect |
1 ms |
388 KB |
Output isn't correct |
24 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
25 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
26 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
27 |
Incorrect |
2 ms |
1172 KB |
Output isn't correct |
28 |
Incorrect |
5 ms |
1560 KB |
Output isn't correct |
29 |
Incorrect |
35 ms |
1760 KB |
Output isn't correct |
30 |
Incorrect |
69 ms |
2660 KB |
Output isn't correct |
31 |
Incorrect |
34 ms |
2048 KB |
Output isn't correct |
32 |
Incorrect |
53 ms |
2148 KB |
Output isn't correct |
33 |
Incorrect |
96 ms |
2736 KB |
Output isn't correct |
34 |
Incorrect |
4 ms |
1300 KB |
Output isn't correct |
35 |
Incorrect |
16 ms |
2736 KB |
Output isn't correct |
36 |
Incorrect |
40 ms |
2736 KB |
Output isn't correct |
37 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
38 |
Execution timed out |
1094 ms |
73912 KB |
Time limit exceeded |
39 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
40 |
Incorrect |
881 ms |
9460 KB |
Output isn't correct |
41 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
42 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
43 |
Execution timed out |
1090 ms |
73972 KB |
Time limit exceeded |
44 |
Incorrect |
138 ms |
2736 KB |
Output isn't correct |
45 |
Execution timed out |
1077 ms |
73916 KB |
Time limit exceeded |
46 |
Execution timed out |
1091 ms |
73880 KB |
Time limit exceeded |
47 |
Execution timed out |
1040 ms |
73880 KB |
Time limit exceeded |
48 |
Execution timed out |
1050 ms |
73956 KB |
Time limit exceeded |
49 |
Incorrect |
449 ms |
74000 KB |
Output isn't correct |
50 |
Execution timed out |
1063 ms |
73872 KB |
Time limit exceeded |
51 |
Execution timed out |
1065 ms |
74004 KB |
Time limit exceeded |
52 |
Execution timed out |
1099 ms |
73956 KB |
Time limit exceeded |
53 |
Execution timed out |
1088 ms |
73944 KB |
Time limit exceeded |
54 |
Execution timed out |
1073 ms |
73956 KB |
Time limit exceeded |
55 |
Execution timed out |
1090 ms |
73972 KB |
Time limit exceeded |
56 |
Execution timed out |
1097 ms |
73872 KB |
Time limit exceeded |
57 |
Execution timed out |
1083 ms |
73864 KB |
Time limit exceeded |
58 |
Execution timed out |
1060 ms |
73956 KB |
Time limit exceeded |
59 |
Execution timed out |
1096 ms |
73884 KB |
Time limit exceeded |
60 |
Execution timed out |
1033 ms |
73880 KB |
Time limit exceeded |
61 |
Execution timed out |
1027 ms |
73988 KB |
Time limit exceeded |
62 |
Execution timed out |
1083 ms |
73884 KB |
Time limit exceeded |
63 |
Execution timed out |
1040 ms |
73960 KB |
Time limit exceeded |
64 |
Execution timed out |
1087 ms |
73964 KB |
Time limit exceeded |
65 |
Execution timed out |
1089 ms |
73892 KB |
Time limit exceeded |
66 |
Incorrect |
587 ms |
73992 KB |
Output isn't correct |
67 |
Execution timed out |
1081 ms |
73924 KB |
Time limit exceeded |
68 |
Execution timed out |
1036 ms |
73956 KB |
Time limit exceeded |
69 |
Execution timed out |
1052 ms |
73984 KB |
Time limit exceeded |
70 |
Execution timed out |
1059 ms |
47476 KB |
Time limit exceeded |
71 |
Execution timed out |
1079 ms |
73956 KB |
Time limit exceeded |
72 |
Execution timed out |
1052 ms |
73892 KB |
Time limit exceeded |
73 |
Execution timed out |
1070 ms |
73956 KB |
Time limit exceeded |
74 |
Execution timed out |
1042 ms |
73876 KB |
Time limit exceeded |
75 |
Execution timed out |
1060 ms |
73908 KB |
Time limit exceeded |
76 |
Execution timed out |
1077 ms |
73888 KB |
Time limit exceeded |
77 |
Execution timed out |
1062 ms |
73952 KB |
Time limit exceeded |
78 |
Execution timed out |
1076 ms |
73928 KB |
Time limit exceeded |
79 |
Execution timed out |
1094 ms |
73956 KB |
Time limit exceeded |
80 |
Execution timed out |
1059 ms |
73880 KB |
Time limit exceeded |
81 |
Execution timed out |
1049 ms |
73976 KB |
Time limit exceeded |
82 |
Execution timed out |
1060 ms |
73880 KB |
Time limit exceeded |
83 |
Execution timed out |
1048 ms |
73876 KB |
Time limit exceeded |
84 |
Incorrect |
957 ms |
73988 KB |
Output isn't correct |
85 |
Execution timed out |
1097 ms |
73976 KB |
Time limit exceeded |
86 |
Execution timed out |
1040 ms |
73976 KB |
Time limit exceeded |
87 |
Execution timed out |
1027 ms |
73876 KB |
Time limit exceeded |
88 |
Execution timed out |
1065 ms |
73916 KB |
Time limit exceeded |
89 |
Execution timed out |
1067 ms |
73916 KB |
Time limit exceeded |
90 |
Execution timed out |
1093 ms |
47424 KB |
Time limit exceeded |
91 |
Execution timed out |
1052 ms |
74032 KB |
Time limit exceeded |
92 |
Execution timed out |
1027 ms |
73924 KB |
Time limit exceeded |
93 |
Execution timed out |
1057 ms |
73916 KB |
Time limit exceeded |
94 |
Execution timed out |
1050 ms |
73956 KB |
Time limit exceeded |
95 |
Execution timed out |
1044 ms |
73956 KB |
Time limit exceeded |
96 |
Execution timed out |
1046 ms |
73956 KB |
Time limit exceeded |
97 |
Execution timed out |
1051 ms |
73920 KB |
Time limit exceeded |
98 |
Execution timed out |
1056 ms |
73980 KB |
Time limit exceeded |
99 |
Execution timed out |
1044 ms |
73912 KB |
Time limit exceeded |
100 |
Execution timed out |
1059 ms |
73920 KB |
Time limit exceeded |