Please sign in first.
Submission #74275802
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
const int di[] = {0, -1, 0, 1}, dj[] = {1, 0, -1, 0};
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int n, m;
cin >> n >> m;
vector<string> g(n);
for (int i=0; i<n; i++) cin >> g[i];
vector<vector<bool>> vis(n, vector<bool>(m, false));
auto dfs = [&](auto &self, int i, int j) -> bool {
if (i < 0 || j < 0 || i >= n || j >= m) return true;
if (g[i][j] == '#' || vis[i][j]) return false;
vis[i][j] = true;
bool ret = false;
for (int k=0; k<4; k++) {
int ni = i + di[k], nj = j + dj[k];
ret |= self(self, ni, nj);
}
return ret;
};
int ans = 0;
for (int i=0; i<n; i++) {
for (int j=0; j<m; j++) {
if (vis[i][j] || g[i][j] == '#') continue;
ans += !dfs(dfs, i, j);
}
}
cout << ans << '\n';
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Puddles |
| User | Wie |
| Language | C++23 (GCC 15.2.0) |
| Score | 300 |
| Code Size | 933 Byte |
| Status | AC |
| Exec Time | 38 ms |
| Memory | 35964 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample_01.txt, sample_02.txt |
| All | min.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, sample_01.txt, sample_02.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| min.txt | AC | 1 ms | 3544 KiB |
| random_01.txt | AC | 9 ms | 4768 KiB |
| random_02.txt | AC | 3 ms | 3948 KiB |
| random_03.txt | AC | 9 ms | 4848 KiB |
| random_04.txt | AC | 5 ms | 4324 KiB |
| random_05.txt | AC | 18 ms | 4732 KiB |
| random_06.txt | AC | 2 ms | 3664 KiB |
| random_07.txt | AC | 18 ms | 4884 KiB |
| random_08.txt | AC | 2 ms | 3588 KiB |
| random_09.txt | AC | 30 ms | 5548 KiB |
| random_10.txt | AC | 23 ms | 5292 KiB |
| random_11.txt | AC | 30 ms | 5792 KiB |
| random_12.txt | AC | 1 ms | 3672 KiB |
| random_13.txt | AC | 37 ms | 21508 KiB |
| random_14.txt | AC | 4 ms | 4884 KiB |
| random_15.txt | AC | 38 ms | 21720 KiB |
| random_16.txt | AC | 13 ms | 9316 KiB |
| random_17.txt | AC | 4 ms | 4880 KiB |
| random_18.txt | AC | 32 ms | 35964 KiB |
| random_19.txt | AC | 7 ms | 4892 KiB |
| random_20.txt | AC | 17 ms | 20432 KiB |
| random_21.txt | AC | 17 ms | 20356 KiB |
| sample_01.txt | AC | 1 ms | 3544 KiB |
| sample_02.txt | AC | 1 ms | 3596 KiB |