結果

問題 No.801 エレベーター
ユーザー noisy_noiminnoisy_noimin
提出日時 2019-03-17 22:48:11
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,673 bytes
コンパイル時間 857 ms
コンパイル使用メモリ 93,796 KB
実行使用メモリ 429,120 KB
最終ジャッジ日時 2023-09-22 09:00:55
合計ジャッジ時間 21,431 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
11,480 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1,733 ms
7,264 KB
testcase_04 AC 1,594 ms
7,388 KB
testcase_05 AC 1,604 ms
7,104 KB
testcase_06 AC 1,550 ms
7,256 KB
testcase_07 AC 1,735 ms
7,264 KB
testcase_08 AC 1,772 ms
7,320 KB
testcase_09 AC 1,786 ms
7,252 KB
testcase_10 AC 1,521 ms
7,216 KB
testcase_11 AC 1,630 ms
7,184 KB
testcase_12 AC 1,603 ms
7,112 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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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< vector<ll> > product(vector< vector<ll> > A, vector< vector<ll> > B){
	int height = A.size(), width = B[0].size(), n = B.size();
	
	vector< vector<ll> > C(height, vector<ll>(width, 0));
	
	for(int i=0;i<height;++i){
		for(int j=0;j<width;++j){
			for(int k=0;k<n;++k){
				C[i][j] += (A[i][k] * B[k][j]) % MOD;
                C[i][j] %= MOD;
			}
		}
	}
	
	return C;
}

vector< vector<ll> > matrix_pow(vector< vector<ll> > A, ll t) {
    int n = A.size();
    vector< vector<ll> > B(n, vector<ll>(n, 0));
    for(int i=0;i<n;++i) B[i][i] = 1;
    while(t){
        if(t & 1){
            B = product(B, A);
        }
        A = product(A, A);
        t >>= 1;
    }
    return B;
}

int main() {
    int n,m,K,l,r;
    cin >> n >> m >> K;

    vector< vector<ll> > A(n, vector<ll>(n, 0LL));
    for(int i=1;i<=m;++i) {
        cin >> l >> r;
        --l; --r;
        for(int j=l;j<=r;++j) {
            ++A[j][l];
            if(r+1 < n) --A[j][r+1];
        }
    }
    for(int i=0;i<n;++i) {
        for(int j=1;j<n;++j) {
            A[i][j] += A[i][j-1];
        }
    }

    cout << matrix_pow(A, K)[0][n-1] << "\n";
}
0