Submission #54570
ソースコード
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 | #include<bits/stdc++.h> using namespace std; int main(){ cin.tie(NULL); ios::sync_with_stdio( false ); int h,w,m,p,sum=0,masu[55][55],n,s; cin>>h>>w; for ( int i=0;i<h;i++){ for ( int j=0;j<w;j++){ cin>>masu[i][j]; if (masu[i][j]==4){ n=i; s=j; masu[i][j]-=4; } } } cin>>m; for ( int i=0;i<m;i++){ cin>>p; if (p==1){ while ( true ){ if (masu[n-1][s]!=1){ n--; if (masu[n][s]==3){ sum++; masu[n][s]-=3; } } else break ; } } if (p==2){ while ( true ){ if (masu[n+1][s]!=1){ n++; if (masu[n][s]==3){ sum++; masu[n][s]-=3; } } else break ; } } if (p==3){ while ( true ){ if (masu[n][s+1]!=1){ s++; if (masu[n][s]==3){ sum++; masu[n][s]-=3; } } else break ; } } if (p==4){ while ( true ){ if (masu[n][s-1]!=1){ s--; if (masu[n][s]==3){ sum++; masu[n][s]-=3; } } else break ; } } } cout<<sum<< '\n' ; return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 0387 - 回れ雛月花 -Easy |
ユーザー名 | NASSUN_ei1906 |
投稿日時 | 2019-09-09 18:30:29 |
言語 | C++ |
状態 | Accepted |
得点 | 3 |
ソースコード長 | 1061 Byte |
最大実行時間 | 55 ms |
最大メモリ使用量 | 656 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 3 / 3 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
spin_input01 | AC | 55 ms | 600 KB |
1
|
spin_input02 | AC | 19 ms | 424 KB |
1
|
spin_input03 | AC | 22 ms | 500 KB |
1
|
spin_input04 | AC | 18 ms | 580 KB |
1
|
spin_input05 | AC | 33 ms | 656 KB |
1
|