Submission #55483

#TimeUsernameProblemLanguageResultExecution timeMemory
55483BTheroBomb (IZhO17_bomb)C++14
100 / 100
360 ms69920 KiB
// Why I am so dumb? :c #include <bits/stdc++.h> #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define fi first #define se second using namespace std; typedef long long ll; short up[2502][2502]; short dw[2502][2502]; char s[2502][2502]; int f[2502]; int n, m, ans; void solve() { scanf("%d %d", &n, &m); for (int i = 0; i < n; ++i) { scanf("%s", s[i]); } int limh = n, limw = m; for (int i = 0; i < n; ++i) { int cur = 0; for (int j = 0; j < m; ++j) { if (s[i][j] == '1') { ++cur; if (j + 1 == m || s[i][j + 1] == '0') { limw = min(limw, cur); } } else { cur = 0; } } } for (int j = 0; j < m; ++j) { int cur = 0; for (int i = 0; i < n; ++i) { if (s[i][j] == '1') { up[i][j] = ++cur; if (i + 1 == n || s[i + 1][j] == '0') { limh = min(limh, cur); } } else { cur = 0; } } } for (int j = 0; j < m; ++j) { int cur = 0; for (int i = n - 1; i >= 0; --i) { if (s[i][j] == '1') { dw[i][j] = ++cur; } else { cur = 0; } } } for (int i = 1; i <= limw; ++i) { f[i] = limh; } for (int i = 0; i < n; ++i) { int cur = 0; short l = 10000, r = 10000; for (int j = 0; j < m; ++j) { if (s[i][j] == '1') { ++cur; l = min(l, up[i][j]); r = min(r, dw[i][j]); f[cur] = min(f[cur], l + r - 1); } else { cur = 0; l = r = 10000; } } } for (int i = 0; i < n; ++i) { int cur = 0; short l = 10000, r = 10000; for (int j = m - 1; j >= 0; --j) { if (s[i][j] == '1') { ++cur; l = min(l, up[i][j]); r = min(r, dw[i][j]); f[cur] = min(f[cur], l + r - 1); } else { cur = 0; l = r = 10000; } } } ans = f[1]; for (int i = 2; i <= limw; ++i) { f[i] = min(f[i], f[i - 1]); ans = max(ans, i * f[i]); } printf("%d\n", ans); } int main() { //freopen("bomb.in", "r", stdin); //freopen("bomb.out", "w", stdout); int tt = 1; while (tt--) { solve(); } return 0; }

Compilation message (stderr)

bomb.cpp: In function 'void solve()':
bomb.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~
bomb.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s", s[i]);
         ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...