Submission #00086


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include<iostream>
using namespace std;
int dy[4]={-1,0,1,0};
int dx[4]={0,1,0,-1};
char maps[100][100];
int w,h;
int dfs(int x,int y);
int main(){
cin>>w>>h;
while(w!=0||h!=0){
int sx,sy;
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
cin>>maps[i][j];
if(maps[i][j]=='@'){
sy=i;
sx=j;
}
}
}
cout<<dfs(sx,sy)<<endl;
cin>>w>>h;
}
return(0);
}
int dfs(int x,int y){
int rec=0;
maps[y][x]='#';
for(int i=0;i<4;i++){
int nx=x+dx[i];
int ny=y+dy[i];
if(nx>=0&&nx<w&&ny>=0&&ny<h&&maps[ny][nx]!='#'){
rec+=dfs(nx,ny);
}
}
return(rec+1);
}

ステータス

項目 データ
問題 0005 - 赤と黒
ユーザー名 ei1630
投稿日時 2018-03-30 13:47:10
言語 C++11
状態 Accepted
得点 15
ソースコード長 661 Byte
最大実行時間 31 ms
最大メモリ使用量 532 KB

セット

セット 得点 Cases
1 ALL 15 / 15 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
b1 AC 21 ms 480 KB
1
b2 AC 31 ms 440 KB
1
b3 AC 18 ms 532 KB
1
b4 AC 19 ms 500 KB
1