Submission #18272


ソースコード

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
#include<stdio.h>
int main(){
int h,w,n,p,loop,loop2,hina=0;
int s[2];
scanf("%d %d",&h,&w);
int m[h][w];
for(loop=0;loop<h;++loop){
for(loop2=0;loop2<w;++loop2){
scanf("%d",&m[loop][loop2]);
if(m[loop][loop2]==4){
s[0]=loop;
s[1]=loop2;
}
}
}
scanf("%d",&n);
for(loop=0;loop<n;++loop){
scanf("%d",&p);
if(p==1){
while(1){
if(m[s[0]-1][s[1]]==1){
break;
}
s[0]-=1;
if(m[s[0]][s[1]]==3){
hina++;
m[s[0]][s[1]]=0;
}
}
}else if(p==2){
while(1){
if(m[s[0]+1][s[1]]==1){
break;
}
s[0]+=1;
if(m[s[0]][s[1]]==3){
hina++;
m[s[0]][s[1]]=0;
}
}
}else if(p==3){
while(1){
if(m[s[0]][s[1]+1]==1){
break;
}
s[1]+=1;
if(m[s[0]][s[1]]==3){
hina++;
m[s[0]][s[1]]=0;
}
}
}else if(p==4){
while(1){
if(m[s[0]][s[1]-1]==1){
break;
}
s[1]-=1;
if(m[s[0]][s[1]]==3){
hina++;
m[s[0]][s[1]]=0;
}
}
}
}
printf("%d\n",hina);
return 0;
}

ステータス

項目 データ
問題 0387 - 回れ雛月花 -Easy
ユーザー名 Wonder /*ei1741*/
投稿日時 2017-05-30 17:04:20
言語 C
状態 Accepted
得点 3
ソースコード長 1053 Byte
最大実行時間 12 ms
最大メモリ使用量 404 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
spin_input01 AC 9 ms 380 KB
1
spin_input02 AC 11 ms 404 KB
1
spin_input03 AC 9 ms 360 KB
1
spin_input04 AC 10 ms 388 KB
1
spin_input05 AC 12 ms 316 KB
1