結果

問題 No.801 エレベーター
ユーザー 41Toame41Toame
提出日時 2019-03-17 22:40:16
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 2,612 bytes
コンパイル時間 1,234 ms
コンパイル使用メモリ 153,044 KB
実行使用メモリ 360,480 KB
最終ジャッジ日時 2023-09-22 08:38:14
合計ジャッジ時間 10,818 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
11,488 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 603 ms
12,740 KB
testcase_04 AC 545 ms
12,716 KB
testcase_05 AC 550 ms
12,688 KB
testcase_06 AC 539 ms
12,704 KB
testcase_07 AC 597 ms
12,628 KB
testcase_08 AC 602 ms
12,816 KB
testcase_09 AC 617 ms
12,564 KB
testcase_10 AC 524 ms
12,684 KB
testcase_11 AC 563 ms
12,592 KB
testcase_12 AC 555 ms
12,516 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 "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

int dp[3010][3010];
int sum[3010][3010];

int N, M;
typedef vector<int> vec;
typedef vector<vec> mat;

mat mul(mat &A, mat &B) {
    mat C(A.size(), vec(B[0].size()));
    for (int i = 0; i < A.size(); i++) {
        for (int k = 0; k < B.size(); k++) {
            for (int j = 0; j < C.size(); j++) {
                C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % mod;
            }
        }
    }
    return C;
}

mat pow(mat A, int n) {
    mat B(A.size(), vec(A.size()));
    for (int i = 0; i < A.size(); i++) {
        B[i][i] = 1;
    }
    while(n > 0) {
        if (n & 1) B = mul(B, A);
        A = mul(A, A);
        n >>= 1;
    }
    return B;
}
void solve(int N, int K) {
    mat A(N, vec(N));
    rep(i, N) rep(j, N) A[i][j] = sum[i + 1][j + 1];
    // rep(i, N) {
    //     rep(j, N) cout << A[i][j];
    //     cout << endl;
    // }
    // cout << endl;
    A = pow(A, K);
    // rep(i, N) {
    //     rep(j, N) cout << A[i][j] << " ";
    //     cout << endl;
    // }
    cout << A[N - 1][0] << endl;
}


signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M, K;
    cin >> N >> M >> K;
    int L[3010], R[3010];
    rep(i, M) cin >> L[i] >> R[i];
    rep(i, M) {
        REP(j, L[i], R[i]) sum[j][j]++;
        REP(j, L[i], R[i]) sum[j][R[i] + 1]--;
    }
    rep(i, N + 1) for(int j = i; j <= N; j++) sum[i][j + 1] += sum[i][j];
    REP(i, 1, N) REP(j, 1, N) sum[i][j] = max(sum[i][j], sum[j][i]);
    // rep(i, N + 2) {
    //     rep(j, N + 2) {
    //         cout << sum[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // cout << endl;
    // dp[0][1] = 1;
    // rep(i, K) {
    //     REP(j, 1, N) {
    //         REP(k, 1, N) {
    //             dp[i + 1][j] += dp[i][k] * sum[k][j]; 
    //             //cout << "dp[" << i + 1 << "][" << j << "] = " << "dp[" << i << "][" << k << "] * " << sum[j][k] << " = " << dp[i + 1][j] << endl;
    //             dp[i + 1][j] %= mod;
    //         }
    //     }
    // }
    // rep(i, K + 1) {
    //     rep(j, N) {
    //         cout << dp[i][j + 1] << " ";
    //     }
    //     cout << endl;
    // }
    solve(N, K);
    //cout << dp[K][N] << endl;

    return 0;
}
0