// 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 long long 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 ll o = 1;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
ll n, m, w, h;
ll a[N][N], pref[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];
}
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];
for(ll i = 1; i <= n; i++){
for(ll j = 1; j <= m; j++){
if(!a[i][j - 1] && a[i][j]){
ll l = j, r = m + 1;
while(r - l > 1){
if(get(i, j, i, md) == md - j + 1) l = md;
else r = md;
}
w = min(w, l - j + 1);
// cout << i << ' ' << j << ' ' << l << '\n';
}
if(!a[i - 1][j] && a[i][j]){
ll l = i, r = n + 1;
while(r - l > 1){
if(get(i, j, md, j) == md - i + 1) l = md;
else r = md;
}
h = min(h, l - i + 1);
// cout << i << ' ' << j << ' ' << l << '\n';
}
}
}
cout << h * w;
}
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)
|
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
1 ms |
4432 KB |
Output is correct |
3 |
Correct |
13 ms |
59900 KB |
Output is correct |
4 |
Correct |
14 ms |
59728 KB |
Output is correct |
5 |
Correct |
2 ms |
2384 KB |
Output is correct |
6 |
Correct |
1 ms |
2384 KB |
Output is correct |
7 |
Correct |
1 ms |
2384 KB |
Output is correct |
8 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
4432 KB |
Output isn't correct |
10 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
11 |
Incorrect |
1 ms |
4432 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
13 |
Correct |
1 ms |
2384 KB |
Output is correct |
14 |
Correct |
1 ms |
4432 KB |
Output is correct |
15 |
Incorrect |
2 ms |
4432 KB |
Output isn't correct |
16 |
Correct |
2 ms |
4432 KB |
Output is correct |
17 |
Correct |
1 ms |
4688 KB |
Output is correct |
18 |
Incorrect |
2 ms |
4688 KB |
Output isn't correct |
19 |
Incorrect |
2 ms |
4944 KB |
Output isn't correct |
20 |
Incorrect |
2 ms |
4944 KB |
Output isn't correct |
21 |
Incorrect |
1 ms |
4688 KB |
Output isn't correct |
22 |
Incorrect |
2 ms |
4944 KB |
Output isn't correct |
23 |
Incorrect |
2 ms |
4944 KB |
Output isn't correct |
24 |
Incorrect |
2 ms |
4944 KB |
Output isn't correct |
25 |
Incorrect |
2 ms |
4944 KB |
Output isn't correct |
26 |
Correct |
2 ms |
5112 KB |
Output is correct |
27 |
Correct |
5 ms |
10320 KB |
Output is correct |
28 |
Incorrect |
5 ms |
10724 KB |
Output isn't correct |
29 |
Incorrect |
6 ms |
13304 KB |
Output isn't correct |
30 |
Incorrect |
6 ms |
13800 KB |
Output isn't correct |
31 |
Incorrect |
6 ms |
13136 KB |
Output isn't correct |
32 |
Incorrect |
7 ms |
13648 KB |
Output isn't correct |
33 |
Incorrect |
7 ms |
15952 KB |
Output isn't correct |
34 |
Incorrect |
5 ms |
4432 KB |
Output isn't correct |
35 |
Incorrect |
7 ms |
16124 KB |
Output isn't correct |
36 |
Correct |
8 ms |
7248 KB |
Output is correct |
37 |
Incorrect |
1 ms |
4432 KB |
Output isn't correct |
38 |
Correct |
118 ms |
98544 KB |
Output is correct |
39 |
Incorrect |
1 ms |
4464 KB |
Output isn't correct |
40 |
Incorrect |
19 ms |
33872 KB |
Output isn't correct |
41 |
Incorrect |
1 ms |
4432 KB |
Output isn't correct |
42 |
Incorrect |
1 ms |
4944 KB |
Output isn't correct |
43 |
Correct |
108 ms |
103460 KB |
Output is correct |
44 |
Incorrect |
9 ms |
15952 KB |
Output isn't correct |
45 |
Incorrect |
109 ms |
98560 KB |
Output isn't correct |
46 |
Correct |
119 ms |
103240 KB |
Output is correct |
47 |
Incorrect |
97 ms |
98580 KB |
Output isn't correct |
48 |
Incorrect |
99 ms |
98384 KB |
Output isn't correct |
49 |
Correct |
97 ms |
98376 KB |
Output is correct |
50 |
Incorrect |
99 ms |
101828 KB |
Output isn't correct |
51 |
Incorrect |
94 ms |
98376 KB |
Output isn't correct |
52 |
Incorrect |
93 ms |
98552 KB |
Output isn't correct |
53 |
Incorrect |
97 ms |
98376 KB |
Output isn't correct |
54 |
Incorrect |
96 ms |
98376 KB |
Output isn't correct |
55 |
Incorrect |
105 ms |
98376 KB |
Output isn't correct |
56 |
Correct |
116 ms |
98376 KB |
Output is correct |
57 |
Incorrect |
114 ms |
98376 KB |
Output isn't correct |
58 |
Incorrect |
110 ms |
98376 KB |
Output isn't correct |
59 |
Incorrect |
113 ms |
103240 KB |
Output isn't correct |
60 |
Correct |
124 ms |
103240 KB |
Output is correct |
61 |
Correct |
119 ms |
98376 KB |
Output is correct |
62 |
Correct |
110 ms |
98376 KB |
Output is correct |
63 |
Correct |
109 ms |
98376 KB |
Output is correct |
64 |
Correct |
117 ms |
101704 KB |
Output is correct |
65 |
Incorrect |
124 ms |
101712 KB |
Output isn't correct |
66 |
Incorrect |
112 ms |
101704 KB |
Output isn't correct |
67 |
Incorrect |
124 ms |
103240 KB |
Output isn't correct |
68 |
Incorrect |
122 ms |
98384 KB |
Output isn't correct |
69 |
Incorrect |
111 ms |
103264 KB |
Output isn't correct |
70 |
Incorrect |
83 ms |
82904 KB |
Output isn't correct |
71 |
Incorrect |
111 ms |
98376 KB |
Output isn't correct |
72 |
Incorrect |
120 ms |
98376 KB |
Output isn't correct |
73 |
Incorrect |
108 ms |
98540 KB |
Output isn't correct |
74 |
Incorrect |
119 ms |
103412 KB |
Output isn't correct |
75 |
Incorrect |
109 ms |
98376 KB |
Output isn't correct |
76 |
Incorrect |
102 ms |
98376 KB |
Output isn't correct |
77 |
Incorrect |
105 ms |
98376 KB |
Output isn't correct |
78 |
Incorrect |
110 ms |
100692 KB |
Output isn't correct |
79 |
Incorrect |
108 ms |
101708 KB |
Output isn't correct |
80 |
Incorrect |
114 ms |
101860 KB |
Output isn't correct |
81 |
Incorrect |
108 ms |
101700 KB |
Output isn't correct |
82 |
Incorrect |
108 ms |
98528 KB |
Output isn't correct |
83 |
Incorrect |
110 ms |
98384 KB |
Output isn't correct |
84 |
Incorrect |
105 ms |
98572 KB |
Output isn't correct |
85 |
Incorrect |
120 ms |
98376 KB |
Output isn't correct |
86 |
Incorrect |
113 ms |
98548 KB |
Output isn't correct |
87 |
Incorrect |
108 ms |
98376 KB |
Output isn't correct |
88 |
Incorrect |
123 ms |
101836 KB |
Output isn't correct |
89 |
Incorrect |
109 ms |
98544 KB |
Output isn't correct |
90 |
Incorrect |
91 ms |
83016 KB |
Output isn't correct |
91 |
Incorrect |
108 ms |
98532 KB |
Output isn't correct |
92 |
Incorrect |
117 ms |
98376 KB |
Output isn't correct |
93 |
Incorrect |
110 ms |
101704 KB |
Output isn't correct |
94 |
Incorrect |
113 ms |
98536 KB |
Output isn't correct |
95 |
Incorrect |
112 ms |
98388 KB |
Output isn't correct |
96 |
Incorrect |
102 ms |
101704 KB |
Output isn't correct |
97 |
Incorrect |
120 ms |
98376 KB |
Output isn't correct |
98 |
Incorrect |
113 ms |
101712 KB |
Output isn't correct |
99 |
Incorrect |
109 ms |
98548 KB |
Output isn't correct |
100 |
Incorrect |
115 ms |
98376 KB |
Output isn't correct |