Submission #76096838
Source Code Expand
Copy
#include <stdio.h>int H, W;char S[1024][1024];void meow(int y, int x) {if (S[y][x] != '.') return;S[y][x] = '!';meow(y, x - 1);meow(y, x + 1);meow(y - 1, x);meow(y + 1, x);}int main(void) {int i, j;int ans = 0;if (scanf("%d%d", &H, &W) != 2) return 1;for (i = 1; i <= H; i++) {if (scanf("%1022s", S[i] + 1) != 1) return 1;}for (i = 1; i <= H; i++) {meow(i, 1);meow(i, W);}for (j = 1; j <= W; j++) {meow(1, j);meow(H, j);}for (i = 1; i <= H; i++) {for (j = 1; j <= W; j++) {if (S[i][j] == '.') {ans++;meow(i, j);}}}printf("%d\n", ans);return 0;}
#include <stdio.h>
int H, W;
char S[1024][1024];
void meow(int y, int x) {
if (S[y][x] != '.') return;
S[y][x] = '!';
meow(y, x - 1);
meow(y, x + 1);
meow(y - 1, x);
meow(y + 1, x);
}
int main(void) {
int i, j;
int ans = 0;
if (scanf("%d%d", &H, &W) != 2) return 1;
for (i = 1; i <= H; i++) {
if (scanf("%1022s", S[i] + 1) != 1) return 1;
}
for (i = 1; i <= H; i++) {
meow(i, 1);
meow(i, W);
}
for (j = 1; j <= W; j++) {
meow(1, j);
meow(H, j);
}
for (i = 1; i <= H; i++) {
for (j = 1; j <= W; j++) {
if (S[i][j] == '.') {
ans++;
meow(i, j);
}
}
}
printf("%d\n", ans);
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Puddles |
| User | mikecat |
| Language | C23 (GCC 14.2.0) |
| Score | 300 |
| Code Size | 671 Byte |
| Status | AC |
| Exec Time | 32 ms |
| Memory | 49376 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 | 0 ms | 1736 KiB |
| random_01.txt | AC | 7 ms | 2656 KiB |
| random_02.txt | AC | 2 ms | 2012 KiB |
| random_03.txt | AC | 7 ms | 2656 KiB |
| random_04.txt | AC | 4 ms | 2528 KiB |
| random_05.txt | AC | 10 ms | 2656 KiB |
| random_06.txt | AC | 1 ms | 1780 KiB |
| random_07.txt | AC | 10 ms | 2652 KiB |
| random_08.txt | AC | 1 ms | 1848 KiB |
| random_09.txt | AC | 13 ms | 3412 KiB |
| random_10.txt | AC | 10 ms | 3296 KiB |
| random_11.txt | AC | 14 ms | 4024 KiB |
| random_12.txt | AC | 1 ms | 1836 KiB |
| random_13.txt | AC | 21 ms | 19636 KiB |
| random_14.txt | AC | 2 ms | 3268 KiB |
| random_15.txt | AC | 21 ms | 19668 KiB |
| random_16.txt | AC | 7 ms | 7252 KiB |
| random_17.txt | AC | 3 ms | 2676 KiB |
| random_18.txt | AC | 32 ms | 49376 KiB |
| random_19.txt | AC | 7 ms | 2648 KiB |
| random_20.txt | AC | 17 ms | 25952 KiB |
| random_21.txt | AC | 17 ms | 26080 KiB |
| sample_01.txt | AC | 0 ms | 1652 KiB |
| sample_02.txt | AC | 0 ms | 1736 KiB |