結果
問題 | No.801 エレベーター |
ユーザー | noisy_noimin |
提出日時 | 2019-03-17 22:55:35 |
言語 | C++11 (gcc 11.4.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,483 bytes |
コンパイル時間 | 888 ms |
コンパイル使用メモリ | 88,104 KB |
実行使用メモリ | 428,300 KB |
最終ジャッジ日時 | 2023-09-22 09:17:41 |
合計ジャッジ時間 | 22,109 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
8,756 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 1,732 ms
7,360 KB |
testcase_04 | AC | 1,574 ms
7,264 KB |
testcase_05 | AC | 1,615 ms
6,912 KB |
testcase_06 | AC | 1,539 ms
7,228 KB |
testcase_07 | AC | 1,751 ms
7,536 KB |
testcase_08 | AC | 1,760 ms
7,448 KB |
testcase_09 | AC | 1,817 ms
7,088 KB |
testcase_10 | AC | 1,497 ms
7,156 KB |
testcase_11 | AC | 1,593 ms
7,040 KB |
testcase_12 | AC | 1,608 ms
7,020 KB |
testcase_13 | TLE | - |
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 <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <cassert> #include <iostream> #include <iomanip> #include <string> #include <stack> #include <queue> #include <vector> #include <map> #include <set> #include <algorithm> #include <numeric> #include <bitset> #define all(c) c.begin(), c.end() #define rall(c) c.rbegin(), c.rend() #define debug(x) cerr << #x << ": " << x << endl using namespace std; typedef long long ll; typedef pair<ll, ll> Pll; typedef pair<int, int> Pii; const ll MOD = 1000000007; vector<ll> product(vector<ll> A, vector<ll> B, int n){ vector<ll> C(n*n, 0); for(int i=0;i<n;++i){ for(int j=0;j<n;++j){ for(int k=0;k<n;++k){ C[i*n+j] += (A[i*n+k] * B[k*n+j]) % MOD; C[i*n+j] %= MOD; } } } return C; } vector<ll> matrix_pow(vector<ll> A, ll t, int n) { vector<ll> B(n*n, 0); for(int i=0;i<n;++i) B[i*n+i] = 1; while(t){ if(t & 1){ B = product(B, A, n); } A = product(A, A, n); t >>= 1; } return B; } int main() { int n,m,K,l,r; cin >> n >> m >> K; vector<ll> A(n*n, 0LL); for(int i=1;i<=m;++i) { cin >> l >> r; --l; --r; for(int j=l;j<=r;++j) { ++A[j*n+l]; if(r+1 < n) --A[j*n+r+1]; } } for(int i=0;i<n;++i) { for(int j=1;j<n;++j) { A[i*n+j] += A[i*n+j-1]; } } cout << matrix_pow(A, K, n)[n-1] << "\n"; }