# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1115375 | adiyer | Bomb (IZhO17_bomb) | C++17 | 191 ms | 77384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// 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 ll o = 1;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
ll n, m, w, h, cur;
ll a[N][N], up[N][N], down[N][N], mx[N];
char c;
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++){
cur = 0;
for(ll j = 1; j <= m; j++){
if(a[i][j]) cur++;
else if(cur) w = min(w, cur), cur = 0;
else cur = 0;
}
if(cur) w = min(w, cur), cur = 0;
}
for(ll i = 1; i <= m; i++){
cur = 0;
for(ll j = 1; j <= n; j++){
if(a[j][i]) cur++;
else if(cur) h = min(h, cur), cur = 0;
else cur = 0;
}
if(cur) h = min(h, cur), cur = 0;
}
for(ll i = 1; i <= m; i++){
cur = 0;
for(ll j = 1; j <= n; j++){
if(a[j][i]) up[j][i] = ++cur;
else cur = 0;
}
cur = 0;
for(ll j = n; j >= 1; j--){
if(a[j][i]) down[j][i] = ++cur;
else cur = 0;
}
}
for(ll i = 1; i <= w; i++) mx[i] = h;
for(ll i = 1; i <= n; i++){
ll mu, md;
mu = md = 1e5;
cur = 0;
for(ll j = 1; j <= m; j++){
if(a[i][j]){
cur++;
mu = min(mu, up[i][j]);
md = min(md, down[i][j]);
mx[cur] = min(mx[cur], mu + md - 1);
}
else{
cur = 0;
mu = md = 1e5;
}
}
mu = md = 1e5;
cur = 0;
for(ll j = m; j >= 1; j--){
if(a[i][j]){
cur++;
mu = min(mu, up[i][j]);
md = min(md, down[i][j]);
mx[cur] = min(mx[cur], mu + md - 1);
}
else{
cur = 0;
mu = md = 1e5;
}
}
}
ll ans = mx[1];
for(ll i = 2; i <= w; i++) mx[i] = min(mx[i], mx[i - 1]), ans = max(ans, mx[i] * 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();
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |