結果

問題 No.2430 Damage Zone
ユーザー Nzt3Nzt3
提出日時 2023-08-19 01:18:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 983 bytes
コンパイル時間 2,351 ms
コンパイル使用メモリ 209,504 KB
実行使用メモリ 11,648 KB
最終ジャッジ日時 2024-05-06 08:27:43
合計ジャッジ時間 3,323 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
7,808 KB
testcase_01 AC 11 ms
6,144 KB
testcase_02 AC 38 ms
10,880 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 41 ms
11,520 KB
testcase_15 AC 40 ms
11,648 KB
testcase_16 AC 41 ms
11,520 KB
testcase_17 AC 7 ms
5,376 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 12 ms
6,528 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 3 ms
5,376 KB
testcase_25 AC 9 ms
5,888 KB
testcase_26 AC 13 ms
6,940 KB
testcase_27 AC 7 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr int mod=998244353;
void ch(int &a,int b){
  a=a+b;
  if(a>=mod)a-=mod;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H,W,K;
  cin>>H>>W>>K;
  vector<string>A(H);
  for(int i=0;i<H;i++){
    cin>>A[i];
  }
  vector dp(H,vector(W,vector(K,0)));
  dp[0][0][0]=1;
  for(int i=0;i<K;i++){
    for(int j=0;j<H;j++){
      for(int k=0;k<W;k++){
        if(A[j][k]=='#')continue;
        if(j+1<H&&A[j+1][k]!='#'){
          if(A[j+1][k]=='o'){
            if(i+1<K)ch(dp[j+1][k][i+1],dp[j][k][i]);
          }else{
            ch(dp[j+1][k][i],dp[j][k][i]);
          }
        }
        if(k+1<W&&A[j][k+1]!='#'){
          if(A[j][k+1]=='o'){
            if(i+1<K)ch(dp[j][k+1][i+1],dp[j][k][i]);
          }else{
            ch(dp[j][k+1][i],dp[j][k][i]);
          }
        }
      }
    }
  }
  int ans=0;
  for(int i=0;i<K;i++){
    ch(ans,dp[H-1][W-1][i]);
  }
  cout<<ans<<'\n';
}
0