結果

問題 No.1521 Playing Musical Chairs Alone
ユーザー aspiaspi
提出日時 2021-05-04 10:58:39
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 225 ms / 2,000 ms
コード長 1,100 bytes
コンパイル時間 2,346 ms
コンパイル使用メモリ 203,912 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 09:44:51
合計ジャッジ時間 5,614 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 3 ms
6,944 KB
testcase_03 AC 3 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 77 ms
6,944 KB
testcase_06 AC 22 ms
6,944 KB
testcase_07 AC 100 ms
6,940 KB
testcase_08 AC 9 ms
6,940 KB
testcase_09 AC 7 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 170 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 3 ms
6,944 KB
testcase_15 AC 188 ms
6,940 KB
testcase_16 AC 225 ms
6,944 KB
testcase_17 AC 209 ms
6,940 KB
testcase_18 AC 202 ms
6,940 KB
testcase_19 AC 201 ms
6,940 KB
testcase_20 AC 213 ms
6,944 KB
testcase_21 AC 218 ms
6,944 KB
testcase_22 AC 67 ms
6,944 KB
testcase_23 AC 169 ms
6,940 KB
testcase_24 AC 204 ms
6,940 KB
testcase_25 AC 93 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i,n)  for(int i=0; i<(int) (n); i++)
const long long mod = 1000000007;

vector<vector<int>> mul(vector<vector<int>>& xx, vector<vector<int>>& yy) {
    int a = xx.size(), b = yy[0].size(), c = yy.size();
    vector<vector<int>> ans(a, vector<int>(b));
    rep(i, a) {
        rep(j, b) {
            rep(k, c) {
                ans[i][j] += (long long)xx[i][k] * (long long)yy[k][j] % mod;
                if (mod <= ans[i][j])ans[i][j] -= mod;
            }
        }
    }
    return ans;
}
signed main() {
    int N, K, L;
    cin >> N >> K >> L;
    vector<vector<int>>path(N, vector<int>(N)), dp(N, vector<int>(N));
    rep(i, N) {
        for (int j = 1; j <= L; j++) {
            path[i][(i + j) % N] = 1;
        }
    }
    rep(i, N) {
        dp[i][i] = 1;
    }
    for (; K; K >>= 1) {
        if (K & 1) {
            dp= mul(dp, path);
        }
        path = mul(path, path);
    }
    rep(i,N){
        cout<<dp[0][i]<<endl;
    }
}
0