| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 731420 | eneskav | Emacs (COCI20_emacs) | C++17 | 1 ms | 340 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <queue>
#include <cstring>
#define int long long
using namespace std;
int dx[4] = {0, 0, -1, 1};
int dy[4] = {-1, 1, 0, 0};
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, m;
    cin >> n >> m;
    bool a[n][m];
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            char c;
            cin >> c;
            a[i][j] = (c == '.');
        }
    }
    int ans = 0;
    bool vis[n][m];
    memset(vis, false, sizeof(vis));
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            if (vis[i][j])
                continue;
            if (a[i][j])
                continue;
            queue<pair<int, int>> q;
            q.push(make_pair(i, j));
            while (!q.empty())
            {
                pair<int, int> p = q.front();
                q.pop();
                int x = p.first, y = p.second;
                if (vis[x][y])
                    continue;
                vis[x][y] = true;
                for (int k = 0; k < 4; ++k)
                {
                    int nx = x + dx[k], ny = y + dy[k];
                    if (nx < 0 || nx >= n || ny < 0 || ny >= m)
                        continue;
                    if (a[nx][ny])
                        continue;
                    q.push(make_pair(nx, ny));
                }
            }
            ++ans;
        }
    }
    cout << ans;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
