Submission #16509


ソースコード

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
#include<iostream>
using namespace std;
int h,w,f[50][50];
int dx[]={-1,1,0,0},dy[]={0,0,1,-1};
main()
{
cin>>h>>w;
for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>f[i][j];
int x,y;
for(int i=0;i<h;i++)for(int j=0;j<w;j++)if(f[i][j]==4)x=i,y=j,f[i][j]=0;
int n;cin>>n;int cnt=0;
for(int i=0;i<n;i++)
{
int p;cin>>p;p--;
while(1){
int tx=x+dx[p],ty=y+dy[p];
if(f[tx][ty]==1)break;
x=tx,y=ty;
if(f[x][y]==3)
{
cnt++;
f[x][y]=0;
}
}
}
cout<<cnt<<endl;
}

ステータス

項目 データ
問題 0387 - 回れ雛月花 -Easy
ユーザー名 kotatsugame
投稿日時 2017-05-03 07:22:34
言語 C++11
状態 Accepted
得点 3
ソースコード長 514 Byte
最大実行時間 22 ms
最大メモリ使用量 480 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
spin_input01 AC 22 ms 480 KB
1
spin_input02 AC 22 ms 464 KB
1
spin_input03 AC 19 ms 448 KB
1
spin_input04 AC 17 ms 428 KB
1
spin_input05 AC 20 ms 400 KB
1