Submission #942252

#TimeUsernameProblemLanguageResultExecution timeMemory
942252atomBomb (IZhO17_bomb)C++17
4 / 100
85 ms31356 KiB
#include "bits/stdc++.h" // @JASPER'S BOILERPLATE using namespace std; using ll = long long; #ifdef JASPER #include "debug.h" #else #define debug(...) 166 #endif signed main() { cin.tie(0) -> sync_with_stdio(0); int n, m; cin >> n >> m; vector <vector <int>> a(n + 5, vector <int> (m + 5, 0)); for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) { char x; cin >> x; a[i][j] = x - '0'; } } //sub1: shortest consecutive 1ss if (n == 1 || m == 1) { if (n == 1) { int ans = 1e9; for (int i = 1; i < m; ++i) { int cur = 1; if (a[1][i] == 0) continue; while (i + 1 < m && a[1][i + 1]) { ++cur; ++i; } ans = min(ans, cur); } cout << ans << "\n"; } if (m == 1) { int ans = 1e9; for (int i = 1; i < n; ++i) { int cur = 1; if (a[i][1] == 0) continue; while (i + 1 < n && a[i + 1][1]) { ++cur; ++i; } ans = min(ans, cur); } cout << ans << "\n"; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...