結果

問題 No.336 門松列列
ユーザー latte0119latte0119
提出日時 2016-01-21 21:19:17
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 1,336 bytes
コンパイル時間 1,183 ms
コンパイル使用メモリ 144,664 KB
実行使用メモリ 69,496 KB
最終ジャッジ日時 2023-09-02 18:45:00
合計ジャッジ時間 2,574 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
60,716 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 2 ms
4,368 KB
testcase_03 AC 2 ms
4,372 KB
testcase_04 AC 104 ms
69,420 KB
testcase_05 AC 1 ms
4,368 KB
testcase_06 AC 16 ms
13,012 KB
testcase_07 AC 42 ms
29,988 KB
testcase_08 AC 71 ms
49,904 KB
testcase_09 AC 101 ms
68,152 KB
testcase_10 AC 104 ms
69,164 KB
testcase_11 AC 104 ms
69,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

const int mod=1000000007;
const int SIZE=2100;
int N;

int dp[SIZE][SIZE][2];

void add(int &t,int f){
    t+=f;
    if(t>=mod)t-=mod;
    else if(t<0)t+=mod;
}

signed main(){
    cin>>N;
    if(N<=2){
        cout<<0<<endl;
        return 0;
    }

    rep(i,N)rep(j,N){
        if(i==j)continue;
        if(i<j){
            dp[2][j-1][0]++;
        }
        else{
            dp[2][j][1]++;
        }
    }

    reps(i,2,N){
        int sum=0;
        for(int j=N-1;j>=0;j--){
            add(dp[i+1][j][1],sum);
            add(sum,dp[i][j][0]);
        }
        sum=0;
        for(int j=0;j<N-i;j++){
            add(sum,dp[i][j][1]);
            add(dp[i+1][j][0],sum);
        }
    }

    int ans=0;
    rep(i,N)rep(j,2)add(ans,dp[N][i][j]);
    cout<<ans<<endl;
    return 0;
}
0