Submission #60518424
Source Code Expand
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void){
int h, w, d; cin >> h >> w >> d;
vector s(h, vector<char>(w));
queue<pair<pair<int, int>, int>> q;
for(int i=0; i<h; i++){
for(int j=0; j<w; j++){
cin >> s[i][j];
if(s[i][j]=='H'){
q.push({{i, j}, 0});
}
}
}
int ans=0;
vector<vector<bool>> seen(h, vector<bool>(w, false));
int dx[4]={0, 1, 0, -1};
int dy[4]={-1, 0, 1, 0};
while(!q.empty()){
auto [co, cnt]=q.front(); q.pop();
auto [ni, nj]=co;
if(seen[ni][nj]||cnt>d) continue;
seen[ni][nj]=true;
for(int k=0; k<4; k++){
int nei=ni+dy[k], nej=nj+dx[k];
if(nei<0||nej<0||nei>=h||nej>=w) continue;
if(s[nei][nej]!='#'){
q.push({{nei, nej}, cnt+1});
}
}
}
for(int i=0; i<h; i++)for(int j=0; j<w; j++) if(seen[i][j]) ans++;
cout << ans << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Humidifier 3 |
User |
Rumain |
Language |
C++ 20 (gcc 12.2) |
Score |
350 |
Code Size |
941 Byte |
Status |
AC |
Exec Time |
69 ms |
Memory |
10688 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
350 / 350 |
Status |
|
|
Set Name |
Test Cases |
Sample |
00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt |
All |
00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 01_test_28.txt, 01_test_29.txt, 01_test_30.txt, 01_test_31.txt, 01_test_32.txt, 01_test_33.txt, 01_test_34.txt, 01_test_35.txt, 01_test_36.txt |
Case Name |
Status |
Exec Time |
Memory |
00_sample_01.txt |
AC |
1 ms |
3540 KB |
00_sample_02.txt |
AC |
1 ms |
3536 KB |
00_sample_03.txt |
AC |
1 ms |
3468 KB |
01_test_01.txt |
AC |
64 ms |
10540 KB |
01_test_02.txt |
AC |
65 ms |
10512 KB |
01_test_03.txt |
AC |
69 ms |
10536 KB |
01_test_04.txt |
AC |
65 ms |
10548 KB |
01_test_05.txt |
AC |
67 ms |
10536 KB |
01_test_06.txt |
AC |
67 ms |
10592 KB |
01_test_07.txt |
AC |
66 ms |
10616 KB |
01_test_08.txt |
AC |
66 ms |
10576 KB |
01_test_09.txt |
AC |
66 ms |
10560 KB |
01_test_10.txt |
AC |
66 ms |
10688 KB |
01_test_11.txt |
AC |
9 ms |
4164 KB |
01_test_12.txt |
AC |
9 ms |
4328 KB |
01_test_13.txt |
AC |
2 ms |
3532 KB |
01_test_14.txt |
AC |
2 ms |
3664 KB |
01_test_15.txt |
AC |
9 ms |
4300 KB |
01_test_16.txt |
AC |
15 ms |
5384 KB |
01_test_17.txt |
AC |
14 ms |
4672 KB |
01_test_18.txt |
AC |
40 ms |
7564 KB |
01_test_19.txt |
AC |
38 ms |
6520 KB |
01_test_20.txt |
AC |
2 ms |
3764 KB |
01_test_21.txt |
AC |
33 ms |
4724 KB |
01_test_22.txt |
AC |
33 ms |
4720 KB |
01_test_23.txt |
AC |
33 ms |
4676 KB |
01_test_24.txt |
AC |
33 ms |
4712 KB |
01_test_25.txt |
AC |
33 ms |
4672 KB |
01_test_26.txt |
AC |
33 ms |
4632 KB |
01_test_27.txt |
AC |
35 ms |
4720 KB |
01_test_28.txt |
AC |
33 ms |
4724 KB |
01_test_29.txt |
AC |
1 ms |
3540 KB |
01_test_30.txt |
AC |
1 ms |
3492 KB |
01_test_31.txt |
AC |
1 ms |
3532 KB |
01_test_32.txt |
AC |
1 ms |
3488 KB |
01_test_33.txt |
AC |
39 ms |
4680 KB |
01_test_34.txt |
AC |
49 ms |
4724 KB |
01_test_35.txt |
AC |
49 ms |
4676 KB |
01_test_36.txt |
AC |
50 ms |
4672 KB |