# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
833634 |
2023-08-22T07:17:33 Z |
vjudge1 |
Bomb (IZhO17_bomb) |
C++17 |
|
1000 ms |
74092 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) {
string s; cin >> s;
for(int i = 0; i < m; i++) {
v[i] = s[i] - '0';
ok |= v[i];
}
}
if(!ok) return void(cout << 0 << '\n');
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 > 0) pref[i][j] += pref[i-1][j];
if(j > 0) 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 > 0) ans -= pref[i1-1][j2];
if(j1 > 0) ans -= pref[i2][j1-1];
if(i1 > 0 && j1 > 0) ans += pref[i1-1][j1-1];
return ans;
};
int ans = 0;
vector b(n, vector<int>(m));
for(int h = 1; h <= n; h++) {
for(int w = 1; w <= m; w++) {
debug(cerr << "h = " << h << " w = " << w << '\n');
for(int i = 0; i+h-1 < n; i++) {
for(int j = 0; j+w-1 < m; j++) {
if(get(i, j, i+h-1, j+w-1) == h * w) {
debug(cerr << i << ' ' << j << '\n');
for(int ii = i; ii < i+h; ii++) {
for(int jj = j; jj < j+w; jj++) {
b[ii][jj] = 1;
}
}
}
}
}
if(a == b) ans = max(ans, h * w);
debug({
for(int i = 0; i+h-1 < n; i++) {
for(int j = 0; j+w-1 < m; j++)
cerr << b[i][j];
cerr << '\n';
}
});
for(int i = 0; i+h-1 < n; i++) {
for(int j = 0; j+w-1 < m; j++)
b[i][j] = 0;
}
}
}
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 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
712 ms |
724 KB |
Output is correct |
4 |
Correct |
272 ms |
724 KB |
Output is correct |
5 |
Correct |
42 ms |
340 KB |
Output is correct |
6 |
Correct |
28 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
10 ms |
340 KB |
Output is correct |
18 |
Correct |
9 ms |
340 KB |
Output is correct |
19 |
Correct |
26 ms |
340 KB |
Output is correct |
20 |
Correct |
34 ms |
340 KB |
Output is correct |
21 |
Correct |
11 ms |
340 KB |
Output is correct |
22 |
Correct |
23 ms |
340 KB |
Output is correct |
23 |
Correct |
64 ms |
424 KB |
Output is correct |
24 |
Correct |
20 ms |
400 KB |
Output is correct |
25 |
Correct |
112 ms |
424 KB |
Output is correct |
26 |
Execution timed out |
1073 ms |
340 KB |
Time limit exceeded |
27 |
Execution timed out |
1046 ms |
1236 KB |
Time limit exceeded |
28 |
Execution timed out |
1049 ms |
1620 KB |
Time limit exceeded |
29 |
Execution timed out |
1044 ms |
1748 KB |
Time limit exceeded |
30 |
Execution timed out |
1043 ms |
2516 KB |
Time limit exceeded |
31 |
Execution timed out |
1047 ms |
2004 KB |
Time limit exceeded |
32 |
Execution timed out |
1060 ms |
2132 KB |
Time limit exceeded |
33 |
Execution timed out |
1061 ms |
2644 KB |
Time limit exceeded |
34 |
Execution timed out |
1051 ms |
1236 KB |
Time limit exceeded |
35 |
Execution timed out |
1050 ms |
2644 KB |
Time limit exceeded |
36 |
Execution timed out |
1046 ms |
2644 KB |
Time limit exceeded |
37 |
Correct |
0 ms |
212 KB |
Output is correct |
38 |
Execution timed out |
1095 ms |
73932 KB |
Time limit exceeded |
39 |
Correct |
1 ms |
212 KB |
Output is correct |
40 |
Execution timed out |
1051 ms |
9428 KB |
Time limit exceeded |
41 |
Correct |
1 ms |
212 KB |
Output is correct |
42 |
Correct |
777 ms |
424 KB |
Output is correct |
43 |
Execution timed out |
1044 ms |
73928 KB |
Time limit exceeded |
44 |
Execution timed out |
1061 ms |
2644 KB |
Time limit exceeded |
45 |
Execution timed out |
1066 ms |
73932 KB |
Time limit exceeded |
46 |
Execution timed out |
1068 ms |
73928 KB |
Time limit exceeded |
47 |
Execution timed out |
1049 ms |
73916 KB |
Time limit exceeded |
48 |
Execution timed out |
1047 ms |
73916 KB |
Time limit exceeded |
49 |
Execution timed out |
1076 ms |
73932 KB |
Time limit exceeded |
50 |
Execution timed out |
1052 ms |
73932 KB |
Time limit exceeded |
51 |
Execution timed out |
1060 ms |
73932 KB |
Time limit exceeded |
52 |
Execution timed out |
1053 ms |
73928 KB |
Time limit exceeded |
53 |
Execution timed out |
1052 ms |
73924 KB |
Time limit exceeded |
54 |
Execution timed out |
1062 ms |
73932 KB |
Time limit exceeded |
55 |
Execution timed out |
1027 ms |
74092 KB |
Time limit exceeded |
56 |
Execution timed out |
1067 ms |
73976 KB |
Time limit exceeded |
57 |
Execution timed out |
1049 ms |
73932 KB |
Time limit exceeded |
58 |
Execution timed out |
1031 ms |
73928 KB |
Time limit exceeded |
59 |
Execution timed out |
1072 ms |
73928 KB |
Time limit exceeded |
60 |
Execution timed out |
1066 ms |
73912 KB |
Time limit exceeded |
61 |
Execution timed out |
1048 ms |
73912 KB |
Time limit exceeded |
62 |
Execution timed out |
1083 ms |
73908 KB |
Time limit exceeded |
63 |
Execution timed out |
1049 ms |
73932 KB |
Time limit exceeded |
64 |
Execution timed out |
1071 ms |
73992 KB |
Time limit exceeded |
65 |
Execution timed out |
1049 ms |
73928 KB |
Time limit exceeded |
66 |
Execution timed out |
1048 ms |
73940 KB |
Time limit exceeded |
67 |
Execution timed out |
1051 ms |
73916 KB |
Time limit exceeded |
68 |
Execution timed out |
1085 ms |
73916 KB |
Time limit exceeded |
69 |
Execution timed out |
1049 ms |
73908 KB |
Time limit exceeded |
70 |
Execution timed out |
1045 ms |
47444 KB |
Time limit exceeded |
71 |
Execution timed out |
1046 ms |
73932 KB |
Time limit exceeded |
72 |
Execution timed out |
1038 ms |
73932 KB |
Time limit exceeded |
73 |
Execution timed out |
1072 ms |
73932 KB |
Time limit exceeded |
74 |
Execution timed out |
1066 ms |
73912 KB |
Time limit exceeded |
75 |
Execution timed out |
1075 ms |
74000 KB |
Time limit exceeded |
76 |
Execution timed out |
1026 ms |
73928 KB |
Time limit exceeded |
77 |
Execution timed out |
1042 ms |
74012 KB |
Time limit exceeded |
78 |
Execution timed out |
1043 ms |
73916 KB |
Time limit exceeded |
79 |
Execution timed out |
1069 ms |
73932 KB |
Time limit exceeded |
80 |
Execution timed out |
1062 ms |
73932 KB |
Time limit exceeded |
81 |
Execution timed out |
1042 ms |
73932 KB |
Time limit exceeded |
82 |
Execution timed out |
1063 ms |
73924 KB |
Time limit exceeded |
83 |
Execution timed out |
1074 ms |
73904 KB |
Time limit exceeded |
84 |
Execution timed out |
1063 ms |
73912 KB |
Time limit exceeded |
85 |
Execution timed out |
1069 ms |
73928 KB |
Time limit exceeded |
86 |
Execution timed out |
1041 ms |
73908 KB |
Time limit exceeded |
87 |
Execution timed out |
1083 ms |
73928 KB |
Time limit exceeded |
88 |
Execution timed out |
1073 ms |
73944 KB |
Time limit exceeded |
89 |
Execution timed out |
1071 ms |
73920 KB |
Time limit exceeded |
90 |
Execution timed out |
1059 ms |
47432 KB |
Time limit exceeded |
91 |
Execution timed out |
1064 ms |
73940 KB |
Time limit exceeded |
92 |
Execution timed out |
1071 ms |
73932 KB |
Time limit exceeded |
93 |
Execution timed out |
1067 ms |
73996 KB |
Time limit exceeded |
94 |
Execution timed out |
1049 ms |
73932 KB |
Time limit exceeded |
95 |
Execution timed out |
1049 ms |
73932 KB |
Time limit exceeded |
96 |
Execution timed out |
1064 ms |
73932 KB |
Time limit exceeded |
97 |
Execution timed out |
1052 ms |
73932 KB |
Time limit exceeded |
98 |
Execution timed out |
1095 ms |
73912 KB |
Time limit exceeded |
99 |
Execution timed out |
1034 ms |
73924 KB |
Time limit exceeded |
100 |
Execution timed out |
1049 ms |
73916 KB |
Time limit exceeded |