Submission #74292992
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
int h, w;
string s[1009];
bool a[1009][1009];
bool closed = true;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
void hanbetu(int x, int y){
a[x][y] = true;
for(int i = 0; i < 4; i++){
if(x + dx[i] != -1 && x + dx[i] != h && y + dy[i] != -1 && y + dy[i] != w){
if(s[x+dx[i]][y+dy[i]] == '.' && a[x+dx[i]][y+dy[i]] == false){
hanbetu(x+dx[i], y+dy[i]);
}
}
else {
closed = false;
}
}
}
int main(void){
cin >> h >> w;
for(int i = 0; i < h; i++){
cin >> s[i];
}
for(int i = 0; i < h; i++){
for(int j = 0; j < w; j++){
a[i][j] = false;
}
}
int count = 0;
for(int i = 0; i < h; i++){
for(int j = 0; j < w; j++){
if(s[i][j] == '#'){
a[i][j] = true;
}
else if(a[i][j] == false) {
closed = true;
hanbetu(i, j);
if(closed){
count++;
}
}
}
}
cout << count << endl;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Puddles |
| User | mrkm1627 |
| Language | C++23 (GCC 15.2.0) |
| Score | 300 |
| Code Size | 1264 Byte |
| Status | AC |
| Exec Time | 35 ms |
| Memory | 37636 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 | 3572 KiB |
| random_01.txt | AC | 17 ms | 6568 KiB |
| random_02.txt | AC | 6 ms | 4108 KiB |
| random_03.txt | AC | 17 ms | 6500 KiB |
| random_04.txt | AC | 9 ms | 5092 KiB |
| random_05.txt | AC | 24 ms | 6404 KiB |
| random_06.txt | AC | 1 ms | 3684 KiB |
| random_07.txt | AC | 24 ms | 6428 KiB |
| random_08.txt | AC | 2 ms | 3588 KiB |
| random_09.txt | AC | 32 ms | 6916 KiB |
| random_10.txt | AC | 24 ms | 6320 KiB |
| random_11.txt | AC | 32 ms | 7276 KiB |
| random_12.txt | AC | 1 ms | 3612 KiB |
| random_13.txt | AC | 35 ms | 17308 KiB |
| random_14.txt | AC | 3 ms | 4708 KiB |
| random_15.txt | AC | 35 ms | 18032 KiB |
| random_16.txt | AC | 11 ms | 8144 KiB |
| random_17.txt | AC | 12 ms | 6544 KiB |
| random_18.txt | AC | 34 ms | 37636 KiB |
| random_19.txt | AC | 15 ms | 6404 KiB |
| random_20.txt | AC | 23 ms | 22052 KiB |
| random_21.txt | AC | 22 ms | 22012 KiB |
| sample_01.txt | AC | 1 ms | 3480 KiB |
| sample_02.txt | AC | 1 ms | 3664 KiB |