답안 #1115354

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1115354 2024-11-20T11:16:35 Z adiyer Bomb (IZhO17_bomb) C++17
96 / 100
154 ms 80216 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 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;
		}
	}
	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;
		}
	}
	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();
    }
}

Compilation message

bomb.cpp:2: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    2 | #pragma optimize ("g",on)
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4432 KB Output is correct
2 Correct 2 ms 6480 KB Output is correct
3 Correct 8 ms 73208 KB Output is correct
4 Correct 9 ms 73040 KB Output is correct
5 Correct 1 ms 4432 KB Output is correct
6 Incorrect 1 ms 4432 KB Output isn't correct
7 Correct 1 ms 4432 KB Output is correct
8 Correct 2 ms 4432 KB Output is correct
9 Correct 2 ms 4432 KB Output is correct
10 Correct 1 ms 4432 KB Output is correct
11 Correct 1 ms 6480 KB Output is correct
12 Correct 1 ms 4576 KB Output is correct
13 Correct 1 ms 4432 KB Output is correct
14 Correct 1 ms 4432 KB Output is correct
15 Correct 2 ms 4432 KB Output is correct
16 Incorrect 1 ms 6480 KB Output isn't correct
17 Correct 3 ms 10576 KB Output is correct
18 Correct 2 ms 10724 KB Output is correct
19 Correct 2 ms 10576 KB Output is correct
20 Correct 2 ms 10576 KB Output is correct
21 Correct 2 ms 6480 KB Output is correct
22 Correct 2 ms 10576 KB Output is correct
23 Correct 2 ms 10744 KB Output is correct
24 Correct 2 ms 10576 KB Output is correct
25 Correct 2 ms 10748 KB Output is correct
26 Correct 2 ms 10576 KB Output is correct
27 Correct 4 ms 16956 KB Output is correct
28 Correct 3 ms 12880 KB Output is correct
29 Correct 4 ms 16976 KB Output is correct
30 Correct 5 ms 16976 KB Output is correct
31 Correct 4 ms 12880 KB Output is correct
32 Correct 4 ms 16976 KB Output is correct
33 Correct 5 ms 19024 KB Output is correct
34 Correct 3 ms 13132 KB Output is correct
35 Correct 4 ms 14928 KB Output is correct
36 Incorrect 6 ms 23120 KB Output isn't correct
37 Correct 1 ms 6480 KB Output is correct
38 Correct 138 ms 80096 KB Output is correct
39 Correct 2 ms 6480 KB Output is correct
40 Correct 20 ms 36176 KB Output is correct
41 Correct 1 ms 6480 KB Output is correct
42 Correct 2 ms 10732 KB Output is correct
43 Correct 118 ms 76760 KB Output is correct
44 Correct 6 ms 23120 KB Output is correct
45 Correct 124 ms 79948 KB Output is correct
46 Correct 111 ms 79948 KB Output is correct
47 Correct 111 ms 79944 KB Output is correct
48 Correct 123 ms 79176 KB Output is correct
49 Correct 145 ms 80200 KB Output is correct
50 Correct 135 ms 79948 KB Output is correct
51 Correct 147 ms 80124 KB Output is correct
52 Correct 128 ms 79960 KB Output is correct
53 Correct 137 ms 79432 KB Output is correct
54 Correct 131 ms 74568 KB Output is correct
55 Correct 111 ms 74068 KB Output is correct
56 Correct 147 ms 80200 KB Output is correct
57 Correct 106 ms 65376 KB Output is correct
58 Correct 116 ms 74832 KB Output is correct
59 Correct 117 ms 73544 KB Output is correct
60 Correct 124 ms 78664 KB Output is correct
61 Incorrect 141 ms 80216 KB Output isn't correct
62 Correct 140 ms 80128 KB Output is correct
63 Correct 154 ms 80200 KB Output is correct
64 Correct 120 ms 76116 KB Output is correct
65 Correct 118 ms 79688 KB Output is correct
66 Correct 123 ms 78700 KB Output is correct
67 Correct 113 ms 80200 KB Output is correct
68 Correct 132 ms 80204 KB Output is correct
69 Correct 94 ms 65608 KB Output is correct
70 Correct 54 ms 45396 KB Output is correct
71 Correct 107 ms 59096 KB Output is correct
72 Correct 99 ms 65096 KB Output is correct
73 Correct 104 ms 65100 KB Output is correct
74 Correct 109 ms 71380 KB Output is correct
75 Correct 117 ms 71752 KB Output is correct
76 Correct 119 ms 71752 KB Output is correct
77 Correct 121 ms 72008 KB Output is correct
78 Correct 120 ms 74316 KB Output is correct
79 Correct 113 ms 46928 KB Output is correct
80 Correct 88 ms 51156 KB Output is correct
81 Correct 91 ms 47432 KB Output is correct
82 Correct 111 ms 75860 KB Output is correct
83 Correct 115 ms 76876 KB Output is correct
84 Correct 92 ms 38984 KB Output is correct
85 Correct 109 ms 78408 KB Output is correct
86 Correct 135 ms 79952 KB Output is correct
87 Correct 106 ms 77896 KB Output is correct
88 Correct 107 ms 79580 KB Output is correct
89 Correct 113 ms 79952 KB Output is correct
90 Correct 71 ms 68168 KB Output is correct
91 Correct 120 ms 78256 KB Output is correct
92 Correct 125 ms 79944 KB Output is correct
93 Correct 142 ms 79960 KB Output is correct
94 Correct 118 ms 79944 KB Output is correct
95 Correct 98 ms 75080 KB Output is correct
96 Correct 102 ms 73544 KB Output is correct
97 Correct 124 ms 79944 KB Output is correct
98 Correct 104 ms 74212 KB Output is correct
99 Correct 103 ms 80052 KB Output is correct
100 Correct 125 ms 80056 KB Output is correct