結果

問題 No.1521 Playing Musical Chairs Alone
ユーザー 夜
提出日時 2021-05-28 21:21:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 160 ms / 2,000 ms
コード長 1,611 bytes
コンパイル時間 1,361 ms
コンパイル使用メモリ 103,272 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 23:36:18
合計ジャッジ時間 3,442 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 45 ms
5,376 KB
testcase_06 AC 33 ms
5,376 KB
testcase_07 AC 65 ms
5,376 KB
testcase_08 AC 6 ms
5,376 KB
testcase_09 AC 6 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 100 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 107 ms
5,376 KB
testcase_16 AC 126 ms
5,376 KB
testcase_17 AC 128 ms
5,376 KB
testcase_18 AC 120 ms
5,376 KB
testcase_19 AC 132 ms
5,376 KB
testcase_20 AC 129 ms
5,376 KB
testcase_21 AC 132 ms
5,376 KB
testcase_22 AC 140 ms
5,376 KB
testcase_23 AC 97 ms
5,376 KB
testcase_24 AC 140 ms
5,376 KB
testcase_25 AC 160 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	long long n, k, l;
	cin >> n >> k >> l;
	long long mod = 1000000007;
	int m_size = n;
	vector<vector<long long>> mat(220);
	long long y = k;
	vector<vector<long long>> ans(220);
	for (int i = 0; i < m_size; i++) {
		for (int j = 0; j < m_size; j++) {
			mat[i].emplace_back(0);
			ans[i].emplace_back(0);
		}
		for (int j = 1; j <= l; j++) {
			mat[i][(i + j) % n]++;
			ans[i][(i + j) % n]++;
		}
	}

	y--;
	while (y > 0) {
		if ((y & 1) == 1) {
			vector<vector<long long>> ans_mem(220);
			for (int i = 0; i < m_size; i++) {
				for (int j = 0; j < m_size; j++) {
					ans_mem[i].emplace_back(0);
				}
			}
			for (int i = 0; i < m_size; i++) {
				for (int j = 0; j < m_size; j++) {
					for (int k = 0; k < m_size; k++) {
						ans_mem[i][j] += ans[i][k] * mat[k][j] % mod;
						ans_mem[i][j] %= mod;
					}
				}
			}
			ans = ans_mem;
		}
		vector<vector<long long>> mat_mem(220);
		for (int i = 0; i < m_size; i++) {
			for (int j = 0; j < m_size; j++) {
				mat_mem[i].emplace_back(0);
			}
		}
		for (int i = 0; i < m_size; i++) {
			for (int j = 0; j < m_size; j++) {
				for (int k = 0; k < m_size; k++) {
					mat_mem[i][j] += mat[i][k] * mat[k][j] % mod;
					mat_mem[i][j] %= mod;
				}
			}
		}
		mat = mat_mem;
		y >>= 1;
	}
	for (int i = 0; i < n; i++) {
		cout << ans[0][i] << endl;
	}
}
0