Submission #218150

#TimeUsernameProblemLanguageResultExecution timeMemory
218150VimmerEmacs (COCI20_emacs)C++14
50 / 50
6 ms384 KiB
#include <bits/stdc++.h> #pragma GCC optimize("unroll-loops") #pragma GCC optimize("-O3") #pragma GCC optimize("Ofast") #define F first #define S second #define sz(x) int(x.size()) #define pb push_back #define N 200005 #define M ll(1000000007) using namespace std; typedef long long ll; int step[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}, x, y, n, m; bool mk[200][200]; string a[200]; bool gd() { for (x = 0; x < n; x++) for (y = 0; y < m; y++) if (a[x][y] == '*' && !mk[x][y]) {mk[x][y] = 1; return 1;} return 0; } queue <pair <int, int> > qr; int main() { //freopen("mining.in","r",stdin); freopen("mining.out","w",stdout); ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 0; i < n; i++) cin >> a[i]; int ans = 0; while (gd()) { qr.push({x, y}); ans++; while (sz(qr) > 0) { int x = qr.front().F; int y = qr.front().S; qr.pop(); for (int i = 0; i < 4; i++) { int cx = x + step[i][0]; int cy = y + step[i][1]; if (cx >= 0 && cx < n && cy >= 0 && cy < m && !mk[cx][cy] && a[cx][cy] == '*') { mk[cx][cy] = 1; qr.push({cx, cy}); } } } } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...