Submission #26133
ソースコード
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 | import java.util.Scanner; import java.util.stream.IntStream; public class Main{ static final Scanner s= new Scanner(System.in); static IntStream REPS( int v){ return IntStream.range(0,v);} static IntStream REPS( int l, int r){ return IntStream.rangeClosed(l,r);} static IntStream INS( int n){ return REPS(n).map(i->getInt());} static int getInt(){ return Integer.parseInt(s.next());} public static void main(String[]$){ int h=getInt(),w=getInt(); int y=0,x=0; int [][]f= new int [h][w]; for ( int i=0;i<h;++i) { for ( int j=0;j<w;++j) { f[i][j]=getInt(); if (f[i][j]==4) { y=i;x=j; f[i][j]=0; } } } int []dx={0,0,1,-1},dy={-1,1,0,0}; int r=0; for ( int q=getInt();q>0;--q) { int d=getInt()-1; loop: while ( true ) { int ny=y+dy[d],nx=x+dx[d]; switch (f[ny][nx]){ case 1: break loop; case 3: ++r; f[ny][nx]=0; case 0: y+=dy[d]; x+=dx[d]; break ; } } } System.out.println(r); } } |
ステータス
項目 | データ |
---|---|
問題 | 0387 - 回れ雛月花 -Easy |
ユーザー名 | fal_rnd |
投稿日時 | 2017-09-04 16:30:19 |
言語 | Java |
状態 | Accepted |
得点 | 3 |
ソースコード長 | 1020 Byte |
最大実行時間 | 87 ms |
最大メモリ使用量 | 14656 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 3 / 3 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
spin_input01 | AC | 87 ms | 13740 KB |
1
|
spin_input02 | AC | 68 ms | 13280 KB |
1
|
spin_input03 | AC | 70 ms | 14624 KB |
1
|
spin_input04 | AC | 71 ms | 14528 KB |
1
|
spin_input05 | AC | 81 ms | 14656 KB |
1
|