Submission #73845


ソースコード

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
#include <bits/stdc++.h>
using namespace std;
int main(){
int h,w,n,p,i,j,hina=0,nhh,nhw;
cin>>h>>w;
vector<vector<int>> m(h,vector<int>(w));
for(i=0;i<h;i++){
for(j=0;j<w;j++){
cin>>m[i][j];
if(m[i][j]==4){
nhh=i;
nhw=j;
m[i][j]=0;
}
}
}
cin>>n;
for(i=0;i<n;i++){
cin>>p;
if(p==1){
while(m[nhh-1][nhw]!=1){
nhh--;
if(m[nhh][nhw]==3){
hina++;
m[nhh][nhw]=0;
}
}
}else if(p==2){
while(m[nhh+1][nhw]!=1){
nhh++;
if(m[nhh][nhw]==3){
hina++;
m[nhh][nhw]=0;
}
}
}else if(p==3){
while(m[nhh][nhw+1]!=1){
nhw++;
if(m[nhh][nhw]==3){
hina++;
m[nhh][nhw]=0;
}
}
}else{
while(m[nhh][nhw-1]!=1){
nhw--;
if(m[nhh][nhw]==3){
hina++;
m[nhh][nhw]=0;
}
}
}
}
cout<<hina<<endl;
return(0);
}

ステータス

項目 データ
問題 0387 - 回れ雛月花 -Easy
ユーザー名 ei2229
投稿日時 2022-11-02 17:37:35
言語 C++17
状態 Accepted
得点 3
ソースコード長 1363 Byte
最大実行時間 51 ms
最大メモリ使用量 604 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
spin_input01 AC 51 ms 604 KB
1
spin_input02 AC 25 ms 448 KB
1
spin_input03 AC 22 ms 416 KB
1
spin_input04 AC 20 ms 388 KB
1
spin_input05 AC 32 ms 484 KB
1