Submission #250840

#TimeUsernameProblemLanguageResultExecution timeMemory
250840NONAMERaspad (COI17_raspad)C++14
0 / 100
6060 ms6068 KiB
#include <bits/stdc++.h> #define dbg(x) cerr << #x << " = " << x << "\n" #define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie() using namespace std; using ll = long long; int n, m; char c[int(1e5) + 10][100]; bool mk[int(1e5) + 10][100]; int f(int l, int r) { int res = 0; queue <pair <int, int> > q; for (int i = l; i <= r; ++i) for (int j = 0; j < m; ++j) mk[i][j] = 0; for (int i = l; i <= r; ++i) for (int j = 0; j < m; ++j) { if (mk[i][j]) continue; ++res; q.push(make_pair(i, j)); while (!q.empty()) { int x = q.front().first, y = q.front().second; q.pop(); for (int xx = -1; xx < 2; ++xx) for (int yy = -1; yy < 2; ++yy) if ((!xx || !yy) && (xx != yy)) { int cx = x + xx; int cy = y + yy; if (cx >= l && cx <= r && cy >= 0 && cy < m && !mk[cx][cy]) { mk[cx][cy] = 1; q.push(make_pair(cx, cy)); } } } } return res; } int main() { fast_io; cin >> n >> m; for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) cin >> c[i][j]; int ans = 0; for (int i = 0; i < n; ++i) for (int j = i; j <= n; ++j) ans += f(i, j); cout << ans << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...