# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
541402 |
2022-03-23T13:24:44 Z |
nigus |
Bomb (IZhO17_bomb) |
C++14 |
|
1000 ms |
56140 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){
int lo = 1;
int hi = minb+1;
while(lo < hi-1){
int mid = (lo+hi)/2;
if(solve(a, mid)){
lo = mid;
}
else{
hi = mid;
}
}
ans = max(ans, ll(a)*ll(lo));
}
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 |
26448 KB |
Output is correct |
4 |
Correct |
11 ms |
26456 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 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 |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
456 KB |
Output is correct |
13 |
Correct |
1 ms |
468 KB |
Output is correct |
14 |
Correct |
1 ms |
460 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
1 ms |
524 KB |
Output is correct |
17 |
Correct |
1 ms |
980 KB |
Output is correct |
18 |
Correct |
1 ms |
724 KB |
Output is correct |
19 |
Correct |
1 ms |
980 KB |
Output is correct |
20 |
Correct |
1 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 |
14 ms |
1096 KB |
Output is correct |
24 |
Correct |
1 ms |
980 KB |
Output is correct |
25 |
Correct |
8 ms |
1236 KB |
Output is correct |
26 |
Correct |
4 ms |
1360 KB |
Output is correct |
27 |
Correct |
3 ms |
4052 KB |
Output is correct |
28 |
Correct |
3 ms |
1620 KB |
Output is correct |
29 |
Execution timed out |
1086 ms |
5204 KB |
Time limit exceeded |
30 |
Correct |
772 ms |
4320 KB |
Output is correct |
31 |
Execution timed out |
1092 ms |
3156 KB |
Time limit exceeded |
32 |
Correct |
83 ms |
4180 KB |
Output is correct |
33 |
Execution timed out |
1093 ms |
5332 KB |
Time limit exceeded |
34 |
Correct |
3 ms |
1748 KB |
Output is correct |
35 |
Correct |
52 ms |
2132 KB |
Output is correct |
36 |
Correct |
766 ms |
6752 KB |
Output is correct |
37 |
Correct |
1 ms |
468 KB |
Output is correct |
38 |
Execution timed out |
1061 ms |
56036 KB |
Time limit exceeded |
39 |
Correct |
1 ms |
468 KB |
Output is correct |
40 |
Execution timed out |
1076 ms |
15872 KB |
Time limit exceeded |
41 |
Correct |
1 ms |
468 KB |
Output is correct |
42 |
Correct |
317 ms |
1364 KB |
Output is correct |
43 |
Execution timed out |
1067 ms |
52164 KB |
Time limit exceeded |
44 |
Execution timed out |
1090 ms |
6100 KB |
Time limit exceeded |
45 |
Execution timed out |
1047 ms |
53468 KB |
Time limit exceeded |
46 |
Execution timed out |
1022 ms |
55948 KB |
Time limit exceeded |
47 |
Execution timed out |
1061 ms |
53564 KB |
Time limit exceeded |
48 |
Execution timed out |
1042 ms |
56012 KB |
Time limit exceeded |
49 |
Correct |
171 ms |
56068 KB |
Output is correct |
50 |
Execution timed out |
1053 ms |
55988 KB |
Time limit exceeded |
51 |
Execution timed out |
1049 ms |
56020 KB |
Time limit exceeded |
52 |
Execution timed out |
1046 ms |
55984 KB |
Time limit exceeded |
53 |
Execution timed out |
1061 ms |
55516 KB |
Time limit exceeded |
54 |
Execution timed out |
1070 ms |
42756 KB |
Time limit exceeded |
55 |
Execution timed out |
1067 ms |
41028 KB |
Time limit exceeded |
56 |
Execution timed out |
1038 ms |
56140 KB |
Time limit exceeded |
57 |
Execution timed out |
1033 ms |
36172 KB |
Time limit exceeded |
58 |
Execution timed out |
1057 ms |
41164 KB |
Time limit exceeded |
59 |
Execution timed out |
1067 ms |
38088 KB |
Time limit exceeded |
60 |
Execution timed out |
1051 ms |
47820 KB |
Time limit exceeded |
61 |
Execution timed out |
1058 ms |
55948 KB |
Time limit exceeded |
62 |
Execution timed out |
1045 ms |
55924 KB |
Time limit exceeded |
63 |
Execution timed out |
1043 ms |
56140 KB |
Time limit exceeded |
64 |
Execution timed out |
1037 ms |
38896 KB |
Time limit exceeded |
65 |
Execution timed out |
1036 ms |
54972 KB |
Time limit exceeded |
66 |
Execution timed out |
1064 ms |
51876 KB |
Time limit exceeded |
67 |
Execution timed out |
1060 ms |
56012 KB |
Time limit exceeded |
68 |
Execution timed out |
1029 ms |
56016 KB |
Time limit exceeded |
69 |
Execution timed out |
1056 ms |
35620 KB |
Time limit exceeded |
70 |
Execution timed out |
1050 ms |
15824 KB |
Time limit exceeded |
71 |
Execution timed out |
1052 ms |
28664 KB |
Time limit exceeded |
72 |
Execution timed out |
1057 ms |
34228 KB |
Time limit exceeded |
73 |
Execution timed out |
1058 ms |
34688 KB |
Time limit exceeded |
74 |
Execution timed out |
1045 ms |
36172 KB |
Time limit exceeded |
75 |
Execution timed out |
1063 ms |
37812 KB |
Time limit exceeded |
76 |
Execution timed out |
1057 ms |
39120 KB |
Time limit exceeded |
77 |
Execution timed out |
1056 ms |
39664 KB |
Time limit exceeded |
78 |
Execution timed out |
1025 ms |
39816 KB |
Time limit exceeded |
79 |
Execution timed out |
1055 ms |
12304 KB |
Time limit exceeded |
80 |
Execution timed out |
1027 ms |
13692 KB |
Time limit exceeded |
81 |
Execution timed out |
1036 ms |
14044 KB |
Time limit exceeded |
82 |
Execution timed out |
1055 ms |
42324 KB |
Time limit exceeded |
83 |
Execution timed out |
1027 ms |
42480 KB |
Time limit exceeded |
84 |
Correct |
267 ms |
7668 KB |
Output is correct |
85 |
Execution timed out |
1056 ms |
41420 KB |
Time limit exceeded |
86 |
Correct |
153 ms |
54824 KB |
Output is correct |
87 |
Execution timed out |
1099 ms |
40196 KB |
Time limit exceeded |
88 |
Execution timed out |
1041 ms |
41036 KB |
Time limit exceeded |
89 |
Execution timed out |
1062 ms |
49864 KB |
Time limit exceeded |
90 |
Execution timed out |
1008 ms |
29860 KB |
Time limit exceeded |
91 |
Execution timed out |
1036 ms |
45004 KB |
Time limit exceeded |
92 |
Execution timed out |
1020 ms |
46676 KB |
Time limit exceeded |
93 |
Correct |
708 ms |
53964 KB |
Output is correct |
94 |
Execution timed out |
1020 ms |
48428 KB |
Time limit exceeded |
95 |
Execution timed out |
1035 ms |
42520 KB |
Time limit exceeded |
96 |
Execution timed out |
1020 ms |
42044 KB |
Time limit exceeded |
97 |
Correct |
412 ms |
54544 KB |
Output is correct |
98 |
Execution timed out |
1040 ms |
41800 KB |
Time limit exceeded |
99 |
Execution timed out |
1031 ms |
48104 KB |
Time limit exceeded |
100 |
Correct |
203 ms |
53304 KB |
Output is correct |