結果
| 問題 |
No.801 エレベーター
|
| コンテスト | |
| ユーザー |
noisy_noimin
|
| 提出日時 | 2019-03-17 22:55:35 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,483 bytes |
| コンパイル時間 | 632 ms |
| コンパイル使用メモリ | 87,812 KB |
| 実行使用メモリ | 429,396 KB |
| 最終ジャッジ日時 | 2024-07-08 01:28:25 |
| 合計ジャッジ時間 | 18,366 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 TLE * 1 -- * 15 |
ソースコード
#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";
}
noisy_noimin