結果
問題 | No.801 エレベーター |
ユーザー | sprng_wl |
提出日時 | 2019-03-17 22:23:15 |
言語 | C++11 (gcc 11.4.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,493 bytes |
コンパイル時間 | 1,536 ms |
コンパイル使用メモリ | 156,456 KB |
実行使用メモリ | 814,928 KB |
最終ジャッジ日時 | 2023-09-22 07:41:11 |
合計ジャッジ時間 | 22,530 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 1,964 ms
15,492 KB |
testcase_04 | AC | 1,952 ms
15,252 KB |
testcase_05 | AC | 1,793 ms
14,604 KB |
testcase_06 | AC | 1,879 ms
14,872 KB |
testcase_07 | AC | 1,983 ms
15,188 KB |
testcase_08 | TLE | - |
testcase_09 | AC | 1,867 ms
14,968 KB |
testcase_10 | AC | 1,836 ms
15,036 KB |
testcase_11 | AC | 1,791 ms
14,644 KB |
testcase_12 | AC | 1,775 ms
14,916 KB |
testcase_13 | MLE | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll MOD = 1e9 + 7; template <typename T> vector<vector<T>> DotMatrix(const vector<vector<T>>& a, const vector<vector<T>>& b){ vector<vector<T>> ret(a.size(), vector<T>(b[0].size(), 0)); for (size_t i = 0; i < ret.size(); ++i) { for (size_t j = 0; j < ret[i].size(); ++j) { for (size_t k = 0; k < b.size(); ++k) { (ret[i][j] += ((a[i][k] * b[k][j]) % MOD)) %= MOD; } } } return ret; } int main() { int N, M, K; cin >> N >> M >> K; vector<vector<ll>> mat(N + 2, vector<ll>(N + 2, 0)); for (int i = 0; i < M; ++i) { int l, r; cin >> l >> r; mat[l][l] += 1; mat[l][r + 1] -= 1; mat[r + 1][l] -= 1; mat[r + 1][r + 1] += 1; } for (int j = 0; j < N + 2; ++j) { for (int i = 0; i < N + 1; ++i) { mat[i + 1][j] += mat[i][j]; } } for (int i = 0; i < N + 2; ++i) { for (int j = 0; j < N + 1; ++j) { mat[i][j + 1] += mat[i][j]; } } vector<vector<vector<ll>>> table(15, vector<vector<ll>>(N + 2, vector<ll>(N + 2, 0))); table[0] = mat; for (int i = 1; i < 15; ++i) { table[i] = DotMatrix(table[i - 1], table[i - 1]); } vector<ll> res(N + 1, 0); res[1] = 1; vector<ll> tmp(N + 1, 0); for (int k = 0; k < 15; ++k) { if ((K>>k & 1) == 0) { continue; } for (int i = 1; i <= N; ++i) { tmp[i] = 0; for (int j = 1; j <= N; ++j) { (tmp[i] += (table[k][i][j] * res[j])) %= MOD; } } res = tmp; } cout << res[N] % MOD << endl; return 0; }