# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
541399 |
2022-03-23T13:17:22 Z |
nigus |
Bomb (IZhO17_bomb) |
C++14 |
|
1000 ms |
57932 KB |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, b, a) for(int i = b - 1; i >= a; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef unsigned long long ull;
unsigned seed = chrono::system_clock::now().time_since_epoch().count();
mt19937 eng(seed);
ll random2(){
return (1ll << 31ll)*eng()+eng();
}
ll n,m,k,q,T;
const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod = 998244353;
const int MAXN = 2501;
bool grid[MAXN][MAXN] = {0};
bool covered[MAXN][MAXN] = {0};
bool can_place(int i, int j, int a, int b){
if(n-i < a || m-j < b)return 0;
rep(c1,0,a){
rep(c2,0,b){
if(!grid[i+c1][j+c2])return 0;
}
}
return 1;
}
bool can_cover(int i, int j, int a, int b){
rep(dx,0,a){
rep(dy,0,b){
int i2 = i - dx;
int j2 = j - dy;
if(i2 >= 0 && j2 >= 0 && can_place(i2,j2,a,b))return 1;
}
}
return 0;
}
bool solve(int a, int b){
rep(c1,0,n){
rep(c2,0,m){
if(grid[c1][c2] && (c1 == n-1 || !grid[c1+1][c2] || c1 == 0 || !grid[c1-1][c2]) && !can_cover(c1,c2,a,b))return 0;
}
}
return 1;
}
int lft[MAXN][MAXN] = {0};
int up[MAXN][MAXN] = {0};
int mina = big;
int minb = big;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
// freopen("fhc.txt","r",stdin);
// freopen("autput.txt","w",stdout);
ll a,b,c,d,e;
cin >> n >> m;
rep(c1,0,n){
string s;
cin >> s;
rep(c2,0,m){
grid[c1][c2] = (s[c2] == '1');
}
}
rep(c1,0,n){
rep(c2,0,m){
if(grid[c1][c2]){
if(c1 == 0){
up[c1][c2] = 1;
}
else{
up[c1][c2] = up[c1-1][c2]+1;
}
if(c1 == n-1 || !grid[c1+1][c2])mina = min(mina, up[c1][c2]);
if(c2 == 0){
lft[c1][c2] = 1;
}
else{
lft[c1][c2] = lft[c1][c2-1]+1;
}
if(c2 == m-1 || !grid[c1][c2+1])minb = min(minb, lft[c1][c2]);
}
}
}
ll ans = 0;
rep(a,1,mina+1){
rep(b,1,minb+1){
if(solve(a, b)){
ans = max(ans, (ll)a*b);
}
}
}
cout << ans << "\n";
return 0;
}
Compilation message
bomb.cpp: In function 'int main()':
bomb.cpp:79:8: warning: unused variable 'a' [-Wunused-variable]
79 | ll a,b,c,d,e;
| ^
bomb.cpp:79:10: warning: unused variable 'b' [-Wunused-variable]
79 | ll a,b,c,d,e;
| ^
bomb.cpp:79:12: warning: unused variable 'c' [-Wunused-variable]
79 | ll a,b,c,d,e;
| ^
bomb.cpp:79:14: warning: unused variable 'd' [-Wunused-variable]
79 | ll a,b,c,d,e;
| ^
bomb.cpp:79:16: warning: unused variable 'e' [-Wunused-variable]
79 | ll a,b,c,d,e;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
12 ms |
26516 KB |
Output is correct |
4 |
Correct |
11 ms |
26404 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
2 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
468 KB |
Output is correct |
13 |
Correct |
1 ms |
468 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
976 KB |
Output is correct |
18 |
Correct |
1 ms |
724 KB |
Output is correct |
19 |
Correct |
2 ms |
980 KB |
Output is correct |
20 |
Correct |
3 ms |
980 KB |
Output is correct |
21 |
Correct |
1 ms |
596 KB |
Output is correct |
22 |
Correct |
1 ms |
724 KB |
Output is correct |
23 |
Correct |
66 ms |
980 KB |
Output is correct |
24 |
Correct |
5 ms |
980 KB |
Output is correct |
25 |
Correct |
73 ms |
1336 KB |
Output is correct |
26 |
Correct |
9 ms |
1364 KB |
Output is correct |
27 |
Correct |
3 ms |
4052 KB |
Output is correct |
28 |
Correct |
7 ms |
1568 KB |
Output is correct |
29 |
Execution timed out |
1073 ms |
5204 KB |
Time limit exceeded |
30 |
Execution timed out |
1080 ms |
4308 KB |
Time limit exceeded |
31 |
Execution timed out |
1086 ms |
3156 KB |
Time limit exceeded |
32 |
Execution timed out |
1047 ms |
4180 KB |
Time limit exceeded |
33 |
Execution timed out |
1076 ms |
5332 KB |
Time limit exceeded |
34 |
Correct |
7 ms |
1748 KB |
Output is correct |
35 |
Execution timed out |
1077 ms |
2140 KB |
Time limit exceeded |
36 |
Execution timed out |
1078 ms |
6744 KB |
Time limit exceeded |
37 |
Correct |
1 ms |
468 KB |
Output is correct |
38 |
Execution timed out |
1027 ms |
57872 KB |
Time limit exceeded |
39 |
Correct |
1 ms |
468 KB |
Output is correct |
40 |
Execution timed out |
1091 ms |
16212 KB |
Time limit exceeded |
41 |
Correct |
1 ms |
468 KB |
Output is correct |
42 |
Execution timed out |
1086 ms |
1364 KB |
Time limit exceeded |
43 |
Execution timed out |
1028 ms |
53940 KB |
Time limit exceeded |
44 |
Execution timed out |
1085 ms |
6228 KB |
Time limit exceeded |
45 |
Execution timed out |
1010 ms |
55576 KB |
Time limit exceeded |
46 |
Execution timed out |
1012 ms |
57772 KB |
Time limit exceeded |
47 |
Execution timed out |
1027 ms |
55364 KB |
Time limit exceeded |
48 |
Execution timed out |
1022 ms |
57824 KB |
Time limit exceeded |
49 |
Correct |
391 ms |
57932 KB |
Output is correct |
50 |
Execution timed out |
1016 ms |
57804 KB |
Time limit exceeded |
51 |
Execution timed out |
1029 ms |
57804 KB |
Time limit exceeded |
52 |
Execution timed out |
1096 ms |
57744 KB |
Time limit exceeded |
53 |
Execution timed out |
1016 ms |
57164 KB |
Time limit exceeded |
54 |
Execution timed out |
1033 ms |
44548 KB |
Time limit exceeded |
55 |
Execution timed out |
1074 ms |
42820 KB |
Time limit exceeded |
56 |
Execution timed out |
1027 ms |
57756 KB |
Time limit exceeded |
57 |
Execution timed out |
1045 ms |
37728 KB |
Time limit exceeded |
58 |
Execution timed out |
1029 ms |
42576 KB |
Time limit exceeded |
59 |
Execution timed out |
1054 ms |
39456 KB |
Time limit exceeded |
60 |
Execution timed out |
1077 ms |
49312 KB |
Time limit exceeded |
61 |
Execution timed out |
1085 ms |
57480 KB |
Time limit exceeded |
62 |
Execution timed out |
1042 ms |
57392 KB |
Time limit exceeded |
63 |
Execution timed out |
1096 ms |
57380 KB |
Time limit exceeded |
64 |
Execution timed out |
1047 ms |
40268 KB |
Time limit exceeded |
65 |
Execution timed out |
1046 ms |
56388 KB |
Time limit exceeded |
66 |
Execution timed out |
1094 ms |
53304 KB |
Time limit exceeded |
67 |
Execution timed out |
1101 ms |
57492 KB |
Time limit exceeded |
68 |
Execution timed out |
1105 ms |
57632 KB |
Time limit exceeded |
69 |
Execution timed out |
1034 ms |
37196 KB |
Time limit exceeded |
70 |
Execution timed out |
1095 ms |
17356 KB |
Time limit exceeded |
71 |
Execution timed out |
1048 ms |
30284 KB |
Time limit exceeded |
72 |
Execution timed out |
1066 ms |
35700 KB |
Time limit exceeded |
73 |
Execution timed out |
1100 ms |
36172 KB |
Time limit exceeded |
74 |
Execution timed out |
1012 ms |
37708 KB |
Time limit exceeded |
75 |
Execution timed out |
1091 ms |
39404 KB |
Time limit exceeded |
76 |
Execution timed out |
1080 ms |
40676 KB |
Time limit exceeded |
77 |
Execution timed out |
1085 ms |
41016 KB |
Time limit exceeded |
78 |
Execution timed out |
1058 ms |
41036 KB |
Time limit exceeded |
79 |
Execution timed out |
1073 ms |
13664 KB |
Time limit exceeded |
80 |
Execution timed out |
1029 ms |
14880 KB |
Time limit exceeded |
81 |
Execution timed out |
1102 ms |
15176 KB |
Time limit exceeded |
82 |
Execution timed out |
1030 ms |
43576 KB |
Time limit exceeded |
83 |
Execution timed out |
1087 ms |
43788 KB |
Time limit exceeded |
84 |
Execution timed out |
1086 ms |
8808 KB |
Time limit exceeded |
85 |
Execution timed out |
1102 ms |
42700 KB |
Time limit exceeded |
86 |
Execution timed out |
1087 ms |
56048 KB |
Time limit exceeded |
87 |
Execution timed out |
1028 ms |
41164 KB |
Time limit exceeded |
88 |
Execution timed out |
1090 ms |
42008 KB |
Time limit exceeded |
89 |
Execution timed out |
1022 ms |
50756 KB |
Time limit exceeded |
90 |
Execution timed out |
1034 ms |
31152 KB |
Time limit exceeded |
91 |
Execution timed out |
1028 ms |
46292 KB |
Time limit exceeded |
92 |
Execution timed out |
1025 ms |
47948 KB |
Time limit exceeded |
93 |
Execution timed out |
1087 ms |
55008 KB |
Time limit exceeded |
94 |
Execution timed out |
1029 ms |
49744 KB |
Time limit exceeded |
95 |
Execution timed out |
1047 ms |
43736 KB |
Time limit exceeded |
96 |
Execution timed out |
1036 ms |
43256 KB |
Time limit exceeded |
97 |
Execution timed out |
1012 ms |
55796 KB |
Time limit exceeded |
98 |
Execution timed out |
1022 ms |
43104 KB |
Time limit exceeded |
99 |
Execution timed out |
1026 ms |
49312 KB |
Time limit exceeded |
100 |
Execution timed out |
1016 ms |
54436 KB |
Time limit exceeded |