Submission #28716


ソースコード

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
71
72
73
74
75
76
#include<bits/stdc++.h>
using namespace std;
int main(){
int h,w,ans=0,sx,sy;
cin>>h>>w;
char map[52][52];
for(int y=0;y<h;y++){
for(int x=0;x<w;x++){
cin>>map[y][x];
if(map[y][x]=='4'){
sx=x;
sy=y;
}
}
}
int m;
cin>>m;
int j,jx=sx,jy=sy;
for(int cnt=0;cnt<m;cnt++){
cin>>j;
if(j==1){
while(1){
if(map[jy-1][jx]=='0' || map[jy-1][jx]=='4'){
jy--;
}else if(map[jy-1][jx]=='3'){
map[jy-1][jx]='0';
ans++;
jy--;
}else{
break;
}
}
}
if(j==2){
while(1){
if(map[jy+1][jx]=='0' || map[jy+1][jx]=='4'){
jy++;
}else if(map[jy+1][jx]=='3'){
map[jy+1][jx]='0';
ans++;
jy++;
}else{
break;
}
}
}
if(j==3){
while(1){
if(map[jy][jx+1]=='0' || map[jy][jx+1]=='4'){
jx++;
}else if(map[jy][jx+1]=='3'){
map[jy][jx+1]='0';
ans++;
jx++;
}else{
break;
}
}
}
if(j==4){
while(1){
if(map[jy][jx-1]=='0' || map[jy][jx-1]=='4'){
jx--;
}else if(map[jy][jx-1]=='3'){
map[jy][jx-1]='0';
ans++;
jx--;
}else{
break;
}
}
}
}
cout<<ans<<endl;
return 0;
}

ステータス

項目 データ
問題 0387 - 回れ雛月花 -Easy
ユーザー名 Zzz..ei1704..Zzz
投稿日時 2017-11-16 18:01:49
言語 C++11
状態 Accepted
得点 3
ソースコード長 1212 Byte
最大実行時間 43 ms
最大メモリ使用量 540 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
spin_input01 AC 43 ms 480 KB
1
spin_input02 AC 38 ms 460 KB
1
spin_input03 AC 20 ms 436 KB
1
spin_input04 AC 23 ms 540 KB
1
spin_input05 AC 25 ms 512 KB
1