Submission #03598


ソースコード

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
#include<bits/stdc++.h>
using namespace std;
#define ANSWER(x) cout<<x<<endl
#define debug(x) cout<<#x<<": "<<x
const int BA = 1000;
const int INFTY = (1<<21);
int main(){
int h,w,n,fx,fy,ans = 0;
int m[51][51];
int p;
int a[4] = {-1,1,0,0};
int b[4] = {0,0,1,-1};
cin >> h >> w;
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
cin >> m[j][i];
if(m[j][i] == 4){
fx = j;
fy = i;
}
}
}
cin >> n;
for(int i=0;i<n;i++){
cin >> p;
while(1){
fx+=b[p-1];
fy+=a[p-1];
if(m[fx][fy] == 1){
fx -=b[p-1];
fy -=a[p-1];
break;
}
if(m[fx][fy] == 3){
m[fx][fy] = 0;
ans ++;
}
}
}
cout << ans << endl;
}

ステータス

項目 データ
問題 0387 - 回れ雛月花 -Easy
ユーザー名 ei1506
投稿日時 2016-04-27 18:18:35
言語 C++11
状態 Accepted
得点 3
ソースコード長 733 Byte
最大実行時間 12 ms
最大メモリ使用量 608 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
spin_input01 AC 11 ms 476 KB
1
spin_input02 AC 10 ms 444 KB
1
spin_input03 AC 11 ms 416 KB
1
spin_input04 AC 12 ms 512 KB
1
spin_input05 AC 12 ms 608 KB
1