結果

問題 No.1521 Playing Musical Chairs Alone
ユーザー yakkiyakki
提出日時 2021-05-28 21:42:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,143 ms / 2,000 ms
コード長 1,348 bytes
コンパイル時間 1,181 ms
コンパイル使用メモリ 118,648 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 23:53:52
合計ジャッジ時間 14,584 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 38 ms
5,248 KB
testcase_02 AC 98 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 566 ms
5,376 KB
testcase_06 AC 79 ms
5,376 KB
testcase_07 AC 769 ms
5,376 KB
testcase_08 AC 157 ms
5,376 KB
testcase_09 AC 264 ms
5,376 KB
testcase_10 AC 25 ms
5,376 KB
testcase_11 AC 715 ms
5,376 KB
testcase_12 AC 7 ms
5,376 KB
testcase_13 AC 35 ms
5,376 KB
testcase_14 AC 70 ms
5,376 KB
testcase_15 AC 878 ms
5,376 KB
testcase_16 AC 930 ms
5,376 KB
testcase_17 AC 819 ms
5,376 KB
testcase_18 AC 957 ms
5,376 KB
testcase_19 AC 1,003 ms
5,376 KB
testcase_20 AC 777 ms
5,376 KB
testcase_21 AC 783 ms
5,376 KB
testcase_22 AC 1,143 ms
5,376 KB
testcase_23 AC 833 ms
5,376 KB
testcase_24 AC 1,015 ms
5,376 KB
testcase_25 AC 607 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<numeric>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0)

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;
//using mint = modint998244353;

int dh[] = {-1,0,1,0};
int dw[] = {0,1,0,-1};

ll dp[2][100];
ll sum[2][101];

int main(){
    int n,k,l; cin >> n >> k >> l;
    dp[0][0] = 1;
    repr(i,1,101) sum[0][i] = 1;
    rep(i,k)rep(j,n){
        dp[(i+1)%2][j] += (sum[i%2][j]-sum[i%2][max(0,j-l)]+MOD)%MOD;
        dp[(i+1)%2][j] %= MOD;
        if(j-l < 0){
            dp[(i+1)%2][j] += (sum[i%2][n]-sum[i%2][n-l+j]+MOD)%MOD;
            dp[(i+1)%2][j] %= MOD;
        }
        sum[(i+1)%2][j+1] = (sum[(i+1)%2][j]+dp[(i+1)%2][j])%MOD;
        if(i != k-1) dp[i%2][j] = 0;
    }
    rep(i,n){
        cout << dp[k%2][i] << endl;
    }
}


0