結果

問題 No.801 エレベーター
ユーザー sugarrrsugarrr
提出日時 2019-03-20 22:46:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,063 bytes
コンパイル時間 1,871 ms
コンパイル使用メモリ 176,192 KB
実行使用メモリ 499,552 KB
最終ジャッジ日時 2023-10-19 04:37:22
合計ジャッジ時間 24,276 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1,924 ms
8,304 KB
testcase_04 AC 1,756 ms
8,264 KB
testcase_05 AC 1,776 ms
8,080 KB
testcase_06 AC 1,723 ms
8,232 KB
testcase_07 AC 1,921 ms
8,332 KB
testcase_08 AC 1,953 ms
8,348 KB
testcase_09 AC 1,990 ms
8,260 KB
testcase_10 AC 1,684 ms
8,148 KB
testcase_11 AC 1,803 ms
8,136 KB
testcase_12 AC 1,797 ms
8,096 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;
typedef long long ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////
typedef vector<ll> vec;
typedef vector<vec> mat;
mat mul(mat a,mat b){/*行列aと行列bの積*/
    mat c(a.size(),vec(b[0].size()));
    for(int i=0;i<a.size();i++){
        for(int j=0;j<b[0].size();j++){
            for(int k=0;k<a[0].size();k++){
                c[i][j]=mod(c[i][j]+a[i][k]*b[k][j]);
            }
        }
    }
    return c;
}

mat pow(mat a,ll n){/*行列aの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;
}
//////////////////////////////////////////
int main(){fastio;
    ll n,m,k;cin>>n>>m>>k;
    ll imos[n+2][n+2];memset(imos,0,sizeof(imos));
    while(m--){
        ll l,r;cin>>l>>r;r++;
        imos[l][l]++;
        imos[l][r]--;
        imos[r][l]--;
        imos[r][r]++;
    }
    rep(i,0,n+1){
        rep(j,0,n){
            imos[i][j+1]+=imos[i][j];
        }
    }
    rep(j,0,n+1){
        rep(i,0,n){
            imos[i+1][j]+=imos[i][j];
        }
    }
    /*rep(i,0,6){
        rep(j,0,6){
            cout<<imos[i][j]<<" ";
        }cout<<endl;
    }*/
    mat a(n+1,vec(n+1));
    rep(i,0,n)rep(j,0,n)a[i][j]=imos[i][j];
    a=pow(a,k);
    mat b(n+1,vec(1));
    b[1][0]=1;
    b=mul(a,b);
    cout<<b[n][0]<<endl;
    
    
    
    return 0;
}






0