Submission #1257374

#TimeUsernameProblemLanguageResultExecution timeMemory
1257374proofyBomb (IZhO17_bomb)C++20
24 / 100
106 ms25032 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int N = 2512; int s[N][N]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) { char c; cin >> c; s[i][j] = c - '0'; } int inf = 1e9; int best_width = inf, best_height = inf; for (int i = 1; i <= n; i++) { vector<pair<int, int>> b; b.reserve(m + 1); b.emplace_back(s[i][1], 1); for (int j = 2; j <= m; j++) if (s[i][j] == s[i][j - 1]) b.back().second += 1; else b.emplace_back(s[i][j], 1); for (auto [x, y] : b) if (x) best_width = min(best_width, y); } for (int j = 1; j <= m; j++) { vector<pair<int, int>> b; b.reserve(n + 1); b.emplace_back(s[1][j], 1); for (int i = 2; i <= n; i++) if (s[i][j] == s[i - 1][j]) b.back().second += 1; else b.emplace_back(s[i][j], 1); for (auto [x, y] : b) if (x) best_height = min(best_height, y); } assert(best_width < inf && best_height < inf); cout << best_width * best_height << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...