結果
| 問題 | 
                            No.801 エレベーター
                             | 
                    
| コンテスト | |
| ユーザー | 
                             sugarrr
                         | 
                    
| 提出日時 | 2019-03-20 22:46:47 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 2,063 bytes | 
| コンパイル時間 | 1,694 ms | 
| コンパイル使用メモリ | 175,312 KB | 
| 実行使用メモリ | 500,480 KB | 
| 最終ジャッジ日時 | 2024-09-19 00:54:12 | 
| 合計ジャッジ時間 | 21,720 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 10 TLE * 1 -- * 15 | 
ソースコード
#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;
}
            
            
            
        
            
sugarrr