結果

問題 No.1766 Tatsujin Remix
ユーザー umezoumezo
提出日時 2021-11-26 23:14:00
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 1,631 bytes
コンパイル時間 3,936 ms
コンパイル使用メモリ 201,008 KB
実行使用メモリ 8,896 KB
最終ジャッジ日時 2023-09-12 05:33:17
合計ジャッジ時間 3,260 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 8 ms
7,800 KB
testcase_10 AC 7 ms
7,900 KB
testcase_11 AC 7 ms
7,784 KB
testcase_12 AC 8 ms
8,104 KB
testcase_13 AC 8 ms
8,016 KB
testcase_14 AC 11 ms
8,660 KB
testcase_15 AC 11 ms
8,704 KB
testcase_16 AC 11 ms
8,748 KB
testcase_17 AC 10 ms
8,676 KB
testcase_18 AC 10 ms
8,724 KB
testcase_19 AC 10 ms
8,896 KB
testcase_20 AC 11 ms
8,756 KB
testcase_21 AC 10 ms
8,732 KB
testcase_22 AC 11 ms
8,680 KB
testcase_23 AC 11 ms
8,696 KB
testcase_24 AC 9 ms
8,832 KB
testcase_25 AC 11 ms
8,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;
 
const int MOD=998244353;
ll dp[200200][3];

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n;
  cin>>n;
  vector<string> S(n);
  rep(i,n) cin>>S[i];
  
  rep(i,16*n){
    int x=i/16;
    int y=i%16;
    int nx=(i+1)/16;
    int ny=(i+1)%16;
    if(i==0){
      if(S[x][y]=='.'){
        dp[i][0]=1;
        if(S[nx][ny]!='k') dp[i][1]=1;
        if(S[nx][ny]!='d') dp[i][2]=1;
      }
      else if(S[x][y]=='d') dp[i][1]=1;
      else if(S[x][y]=='k') dp[i][2]=1;
      continue; 
    }
    if(i%2==0 && S[x][y]=='d'){
      dp[i][1]=(dp[i-1][0]+dp[i-1][1]+dp[i-1][2])%MOD;
    }
    else if(i%2==0 && S[x][y]=='k'){
      dp[i][2]=(dp[i-1][0]+dp[i-1][1]+dp[i-1][2])%MOD;
    }
    else if(i%2==1 && S[x][y]=='d'){
      dp[i][1]=(dp[i-1][1]+dp[i-1][2])%MOD;
    }
    else if(i%2==1 && S[x][y]=='k'){
      dp[i][2]=(dp[i-1][1]+dp[i-1][2])%MOD;
    }
    else if(i%2==0 && S[x][y]=='.'){
      dp[i][0]=dp[i-1][0];
      if((nx<n && S[nx][ny]!='d') || nx==n) dp[i][1]=(dp[i-1][0]+dp[i-1][1]+dp[i-1][2])%MOD;
      if((nx<n && S[nx][ny]!='k') || nx==n) dp[i][2]=(dp[i-1][0]+dp[i-1][1]+dp[i-1][2])%MOD;
    }
    else if(i%2==1 && S[x][y]=='.'){
      dp[i][0]=(dp[i-1][0]+dp[i-1][1]+dp[i-1][2])%MOD;
      if((nx<n && S[nx][ny]!='d') || nx==n) dp[i][1]=(dp[i-1][1]+dp[i-1][2])%MOD;
      if((nx<n && S[nx][ny]!='k') || nx==n) dp[i][2]=(dp[i-1][1]+dp[i-1][2])%MOD;
    }
  }
  cout<<(dp[16*n-1][0]+dp[16*n-1][1]+dp[16*n-1][2])%MOD<<endl;

  return 0;
}
0