Submission #00040


ソースコード

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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define all(v2) v2.begin(),v2.end()
#define fi first
#define se second
#define P pair<int,int>
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
int mod=1e9+7;
int inf=INT_MAX;
int dy[]={1,0,-1,0};
int dx[]={0,-1,0,1};
//cout<<fixed<<setprecision(5);
int main(){
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
int h,w,Q; cin>>h>>w>>Q;
vector<vector<char>> ma(h+1,vector<char>(w+1));
int gh,gw;
for(int i=1;i<=h;i++){
for(int j=1;j<=w;j++){
cin>>ma[i][j];
if(ma[i][j]=='G'){
gh=i;
gw=j;
}
}
}
vector<vector<int>> cost(h+1,vector<int>(w+1,inf));
queue<P> q;
cost[gh][gw]=0;
q.emplace(gh,gw);
while(!q.empty()){
int y,x;
tie(y,x)=q.front();
q.pop();
for(int i=0;i<4;i++){
int ny=y+dy[i];
int nx=x+dx[i];
if(1<=ny && ny<=h && 1<=nx && nx<=w && ma[ny][nx]=='.' && cost[ny][nx]==inf){
cost[ny][nx]=cost[y][x]+1;
q.emplace(ny,nx);
}
}
}
while(1){
int sh,sw; cin>>sh>>sw;
if(sh+sw==0) break;
if(cost[sh][sw]>Q){
cout<<"Broadcasting accident\n";
}
else{
cout<<cost[sh][sw]<<"\n";
}
}
return 0;
}

ステータス

項目 データ
問題 0011 - 魔女っ娘ヒナくるん -Magic.47
ユーザー名 ei2005
投稿日時 2022-05-24 16:26:37
言語 C++17
状態 Accepted
得点 10
ソースコード長 1512 Byte
最大実行時間 163 ms
最大メモリ使用量 8764 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
Input01 AC 23 ms 476 KB
1
Input02 AC 18 ms 432 KB
1
Input03 AC 19 ms 516 KB
1
Input04 AC 30 ms 596 KB
1
Input05 AC 24 ms 872 KB
1
Input06 AC 34 ms 1928 KB
1
Input07 AC 27 ms 1884 KB
1
Input08 AC 27 ms 1848 KB
1
Input09 AC 43 ms 4628 KB
1
Input10 AC 78 ms 6120 KB
1
die. AC 163 ms 8764 KB
1