結果

問題 No.314 ケンケンパ
ユーザー imulanimulan
提出日時 2016-02-08 21:45:43
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 863 bytes
コンパイル時間 1,195 ms
コンパイル使用メモリ 159,500 KB
実行使用メモリ 10,184 KB
最終ジャッジ日時 2023-10-21 20:25:50
合計ジャッジ時間 1,996 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 3 ms
6,012 KB
testcase_02 AC 3 ms
6,012 KB
testcase_03 AC 4 ms
6,012 KB
testcase_04 AC 3 ms
6,012 KB
testcase_05 AC 3 ms
6,012 KB
testcase_06 AC 3 ms
6,012 KB
testcase_07 AC 3 ms
6,012 KB
testcase_08 AC 3 ms
6,012 KB
testcase_09 AC 4 ms
6,012 KB
testcase_10 AC 3 ms
6,020 KB
testcase_11 AC 3 ms
6,028 KB
testcase_12 AC 3 ms
6,036 KB
testcase_13 AC 3 ms
6,048 KB
testcase_14 AC 3 ms
6,248 KB
testcase_15 AC 3 ms
6,424 KB
testcase_16 AC 5 ms
7,060 KB
testcase_17 AC 8 ms
10,172 KB
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(i=0;i<n;++i)
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define mp make_pair
#define pb push_back
#define fi first
#define sc second

const long mod=1e9+7;
long n;

//今x歩まで進んできて、ケンがy回連続している
long dp[100001][3];
long rec(long x, long y){
  if(dp[x][y]>=0) return dp[x][y];

  long ret=0;
  if(x==n) ret=1;
  else{
    if(y==0){//ケンしか置けない
      ret=rec(x+1,y+1);
    }
    else if(y==1){//両方おける
      ret=rec(x+1,y+1)+rec(x+1,0);
    }
    else if(y==2){//パしか置けない
      ret=rec(x+1,0);
    }
  }

  return dp[x][y]=ret%mod;
}

int main(int argc, char const *argv[]) {
  cin >>n;
  memset(dp,-1,sizeof(dp));
  std::cout << rec(0,0) << std::endl;
  return 0;
}
0