# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1114103 |
2024-11-18T07:51:34 Z |
adiyer |
Bomb (IZhO17_bomb) |
C++17 |
|
1000 ms |
76480 KB |
// 194.67
#pragma optimize ("g",on)
#pragma GCC optimize("inline")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("03")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx2,mmx,fma,avx,tune=native")
#include <bits/stdc++.h>
#define file(s) freopen(s".in", "r", stdin); freopen(s".out", "w", stdout);
#define adiyer(); ios_base::sync_with_stdio(0); cin.tie(0);
#define bitcount(n) __builtin_popcountll(n)
#define puts(x) cout << (x ? "YES\n" : "NO\n");
#define ent (i == n ? '\n' : ' ')
#define all(x) x.begin(), x.end()
#define md ((l + r) >> 1)
#define rv(v) ((v << 1) | 1)
#define lv(v) (v << 1)
#define rs(v) rv(v), md + 1, r
#define ls(v) lv(v), l, md
#define len(s) (int) s.size()
#define yes { cout << "YES\n"; return; }
#define no { cout << "NO\n"; return; }
#define skip continue
#define pb push_back
#define S second
#define F first
#define ne !=
// #define int long long
using namespace std;
typedef int ll;
typedef long double ld;
typedef vector < ll > vll;
typedef pair < ll, ll > pll;
typedef vector < pair < ll, ll > > vpll;
const int dx[8] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};
const int N = 2.5e3 + 5;
const int K = 1e5 + 3;
const int MAX = 1e6;
const int mod = 998244353;
const long long inf = 2e9;
const long long one = 1;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
ll n, m, w, h;
ll a[N][N], pref[N][N];
int st[N][N];
char c;
ll get(ll l1, ll r1, ll l2, ll r2){
return pref[l2][r2] - pref[l1 - 1][r2] - pref[l2][r1 - 1] + pref[l1 - 1][r1 - 1];
}
bool f(ll W, ll H){
memset(st, 0, sizeof(st));
for(ll i = 1; i <= n; i++){
for(ll j = 1; j <= m; j++){
if(get(i, j, i + H - 1, j + W - 1) >= H * W){
st[i][j]++;
st[i + H][j]--;
st[i][j + W]--;
st[i + H][j + W]++;
}
st[i][j] += st[i - 1][j] + st[i][j - 1] - st[i - 1][j - 1];
if(a[i][j] && !st[i][j]) return 0;
}
}
return 1;
}
long long ff(ll H){
ll l = 0, r = m + 1;
while(r - l > 1){
if(f(md, H)) l = md;
else r = md;
}
return one * l * H;
}
void output(){
cin >> n >> m, w = m, h = n;
for(ll i = 1; i <= n; i++)
for(ll j = 1; j <= m; j++)
cin >> c, a[i][j] = c - '0';
for(ll i = 1; i <= n; i++)
for(ll j = 1; j <= m; j++)
pref[i][j] = pref[i - 1][j] + pref[i][j - 1] - pref[i - 1][j - 1] + a[i][j];
ll l = 0, r = n + 1;
while(r - l > 2){
ll m1 = l + (r - l) / 3;
ll m2 = r - (r - l) / 3;
if(ff(m1) < ff(m2)) l = m1;
else r = m2;
}
long long ans = 0;
for(ll i = max(1, l - 50); i <= min(n, r + 50); i++) ans = max(ans, ff(i));
cout << ans;
}
const bool cases = 0;
signed main(){
// file("disrupt");
adiyer();
int tt = 1;
if(cases) cin >> tt;
for(int i = 1; i <= tt; i++){
// cout << "Case " << i << ":\n";
output();
// slow();
// stress();
}
}
Compilation message
bomb.cpp:2: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
2 | #pragma optimize ("g",on)
|
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
26960 KB |
Output is correct |
2 |
Correct |
25 ms |
26960 KB |
Output is correct |
3 |
Correct |
110 ms |
59640 KB |
Output is correct |
4 |
Correct |
94 ms |
59472 KB |
Output is correct |
5 |
Correct |
11 ms |
26960 KB |
Output is correct |
6 |
Correct |
10 ms |
27068 KB |
Output is correct |
7 |
Correct |
30 ms |
26960 KB |
Output is correct |
8 |
Correct |
78 ms |
26960 KB |
Output is correct |
9 |
Correct |
70 ms |
27168 KB |
Output is correct |
10 |
Correct |
55 ms |
26960 KB |
Output is correct |
11 |
Correct |
83 ms |
26960 KB |
Output is correct |
12 |
Correct |
72 ms |
26960 KB |
Output is correct |
13 |
Correct |
55 ms |
26960 KB |
Output is correct |
14 |
Correct |
71 ms |
26960 KB |
Output is correct |
15 |
Correct |
69 ms |
26960 KB |
Output is correct |
16 |
Correct |
78 ms |
26960 KB |
Output is correct |
17 |
Correct |
210 ms |
29432 KB |
Output is correct |
18 |
Correct |
209 ms |
29264 KB |
Output is correct |
19 |
Correct |
387 ms |
29516 KB |
Output is correct |
20 |
Correct |
346 ms |
29520 KB |
Output is correct |
21 |
Correct |
263 ms |
29264 KB |
Output is correct |
22 |
Correct |
288 ms |
29264 KB |
Output is correct |
23 |
Correct |
346 ms |
29520 KB |
Output is correct |
24 |
Correct |
314 ms |
29464 KB |
Output is correct |
25 |
Correct |
450 ms |
29520 KB |
Output is correct |
26 |
Correct |
349 ms |
29564 KB |
Output is correct |
27 |
Correct |
431 ms |
34384 KB |
Output is correct |
28 |
Correct |
446 ms |
34384 KB |
Output is correct |
29 |
Correct |
874 ms |
34456 KB |
Output is correct |
30 |
Incorrect |
794 ms |
34384 KB |
Output isn't correct |
31 |
Incorrect |
589 ms |
34572 KB |
Output isn't correct |
32 |
Incorrect |
719 ms |
34384 KB |
Output isn't correct |
33 |
Incorrect |
869 ms |
36664 KB |
Output isn't correct |
34 |
Correct |
400 ms |
32924 KB |
Output is correct |
35 |
Correct |
633 ms |
36868 KB |
Output is correct |
36 |
Correct |
972 ms |
36668 KB |
Output is correct |
37 |
Correct |
81 ms |
27144 KB |
Output is correct |
38 |
Execution timed out |
1066 ms |
74056 KB |
Time limit exceeded |
39 |
Correct |
91 ms |
26960 KB |
Output is correct |
40 |
Execution timed out |
1059 ms |
44624 KB |
Time limit exceeded |
41 |
Correct |
69 ms |
26960 KB |
Output is correct |
42 |
Correct |
340 ms |
29520 KB |
Output is correct |
43 |
Execution timed out |
1066 ms |
74056 KB |
Time limit exceeded |
44 |
Execution timed out |
1041 ms |
36432 KB |
Time limit exceeded |
45 |
Execution timed out |
1073 ms |
73952 KB |
Time limit exceeded |
46 |
Execution timed out |
1061 ms |
74056 KB |
Time limit exceeded |
47 |
Execution timed out |
1087 ms |
73908 KB |
Time limit exceeded |
48 |
Incorrect |
804 ms |
73956 KB |
Output isn't correct |
49 |
Execution timed out |
1060 ms |
74056 KB |
Time limit exceeded |
50 |
Incorrect |
778 ms |
74088 KB |
Output isn't correct |
51 |
Incorrect |
743 ms |
73956 KB |
Output isn't correct |
52 |
Incorrect |
727 ms |
74092 KB |
Output isn't correct |
53 |
Incorrect |
750 ms |
74216 KB |
Output isn't correct |
54 |
Incorrect |
911 ms |
74100 KB |
Output isn't correct |
55 |
Execution timed out |
1061 ms |
74056 KB |
Time limit exceeded |
56 |
Execution timed out |
1031 ms |
75080 KB |
Time limit exceeded |
57 |
Execution timed out |
1076 ms |
74056 KB |
Time limit exceeded |
58 |
Execution timed out |
1068 ms |
73964 KB |
Time limit exceeded |
59 |
Execution timed out |
1042 ms |
73956 KB |
Time limit exceeded |
60 |
Incorrect |
909 ms |
74056 KB |
Output isn't correct |
61 |
Incorrect |
768 ms |
74088 KB |
Output isn't correct |
62 |
Execution timed out |
1051 ms |
75336 KB |
Time limit exceeded |
63 |
Execution timed out |
1072 ms |
74056 KB |
Time limit exceeded |
64 |
Execution timed out |
1041 ms |
74056 KB |
Time limit exceeded |
65 |
Incorrect |
895 ms |
74060 KB |
Output isn't correct |
66 |
Incorrect |
817 ms |
74056 KB |
Output isn't correct |
67 |
Incorrect |
850 ms |
73960 KB |
Output isn't correct |
68 |
Incorrect |
828 ms |
74088 KB |
Output isn't correct |
69 |
Execution timed out |
1069 ms |
74056 KB |
Time limit exceeded |
70 |
Execution timed out |
1060 ms |
68168 KB |
Time limit exceeded |
71 |
Execution timed out |
1066 ms |
74056 KB |
Time limit exceeded |
72 |
Execution timed out |
1069 ms |
74056 KB |
Time limit exceeded |
73 |
Execution timed out |
1046 ms |
73952 KB |
Time limit exceeded |
74 |
Execution timed out |
1065 ms |
73968 KB |
Time limit exceeded |
75 |
Execution timed out |
1036 ms |
73968 KB |
Time limit exceeded |
76 |
Execution timed out |
1060 ms |
74056 KB |
Time limit exceeded |
77 |
Execution timed out |
1059 ms |
74988 KB |
Time limit exceeded |
78 |
Execution timed out |
1053 ms |
74056 KB |
Time limit exceeded |
79 |
Execution timed out |
1058 ms |
74056 KB |
Time limit exceeded |
80 |
Execution timed out |
1061 ms |
74056 KB |
Time limit exceeded |
81 |
Execution timed out |
1073 ms |
74056 KB |
Time limit exceeded |
82 |
Execution timed out |
1053 ms |
74060 KB |
Time limit exceeded |
83 |
Execution timed out |
1055 ms |
74056 KB |
Time limit exceeded |
84 |
Execution timed out |
1060 ms |
73940 KB |
Time limit exceeded |
85 |
Execution timed out |
1071 ms |
74056 KB |
Time limit exceeded |
86 |
Execution timed out |
1067 ms |
74056 KB |
Time limit exceeded |
87 |
Execution timed out |
1076 ms |
74080 KB |
Time limit exceeded |
88 |
Execution timed out |
1064 ms |
74056 KB |
Time limit exceeded |
89 |
Execution timed out |
1066 ms |
73936 KB |
Time limit exceeded |
90 |
Execution timed out |
1078 ms |
67144 KB |
Time limit exceeded |
91 |
Execution timed out |
1055 ms |
74056 KB |
Time limit exceeded |
92 |
Execution timed out |
1047 ms |
74060 KB |
Time limit exceeded |
93 |
Execution timed out |
1049 ms |
74568 KB |
Time limit exceeded |
94 |
Execution timed out |
1060 ms |
73916 KB |
Time limit exceeded |
95 |
Execution timed out |
1040 ms |
75076 KB |
Time limit exceeded |
96 |
Execution timed out |
1035 ms |
76480 KB |
Time limit exceeded |
97 |
Execution timed out |
1036 ms |
74056 KB |
Time limit exceeded |
98 |
Execution timed out |
1061 ms |
73948 KB |
Time limit exceeded |
99 |
Execution timed out |
1052 ms |
73972 KB |
Time limit exceeded |
100 |
Execution timed out |
1069 ms |
74060 KB |
Time limit exceeded |