Submission #886296

#TimeUsernameProblemLanguageResultExecution timeMemory
886296boris_mihovBomb (IZhO17_bomb)C++17
24 / 100
64 ms111260 KiB
#include <algorithm> #include <iostream> #include <numeric> #include <cassert> #include <bitset> #include <vector> typedef long long llong; const int MAXN = 2500 + 10; int n, m; int l[MAXN][MAXN]; int r[MAXN][MAXN]; int u[MAXN][MAXN]; int d[MAXN][MAXN]; char s[MAXN][MAXN]; void solve() { for (int i = 1 ; i <= n ; ++i) { for (int j = 1 ; j <= m ; ++j) { if (s[i][j] == '0') { l[i][j] = u[i][j] = 0; } else { l[i][j] = l[i][j - 1] + 1; u[i][j] = u[i - 1][j] + 1; } } } for (int i = n ; i >= 1 ; --i) { for (int j = m ; j >= 1 ; --j) { if (s[i][j] == '0') { r[i][j] = d[i][j] = 0; } else { r[i][j] = r[i][j + 1] + 1; d[i][j] = d[i + 1][j] + 1; } } } int maxLR = m, maxUD = n; for (int i = 1 ; i <= n ; ++i) { for (int j = 1 ; j <= m ; ++j) { if (s[i][j] == '0') continue; maxLR = std::min(maxLR, l[i][j] + r[i][j] - 1); maxUD = std::min(maxUD, u[i][j] + d[i][j] - 1); } } std::cout << maxLR * maxUD << '\n'; } void input() { std::cin >> n >> m; for (int i = 1 ; i <= n ; ++i) { std::cin >> s[i] + 1; } } void fastIOI() { std::ios_base :: sync_with_stdio(0); std::cout.tie(nullptr); std::cin.tie(nullptr); } int main() { fastIOI(); input(); solve(); return 0; }

Compilation message (stderr)

bomb.cpp: In function 'void input()':
bomb.cpp:69:26: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   69 |         std::cin >> s[i] + 1;
      |                     ~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...