結果
| 問題 |
No.801 エレベーター
|
| コンテスト | |
| ユーザー |
sugarrr
|
| 提出日時 | 2019-03-20 22:44:37 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 2,076 bytes |
| コンパイル時間 | 1,862 ms |
| コンパイル使用メモリ | 175,116 KB |
| 実行使用メモリ | 1,008,952 KB |
| 最終ジャッジ日時 | 2024-09-19 00:53:35 |
| 合計ジャッジ時間 | 8,239 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | MLE * 1 -- * 2 |
| other | -- * 26 |
ソースコード
#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;
}
//////////////////////////////////////////
#define N 3005
int main(){fastio;
ll n,m,k;cin>>n>>m>>k;
ll imos[N][N];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-2){
imos[i][j+1]+=imos[i][j];
}
}
rep(j,0,N-1){
rep(i,0,N-2){
imos[i+1][j]+=imos[i][j];
}
}
/*rep(i,0,6){
rep(j,0,6){
cout<<imos[i][j]<<" ";
}cout<<endl;
}*/
mat a(N,vec(N));
rep(i,0,N-1)rep(j,0,N-1)a[i][j]=imos[i][j];
a=pow(a,k);
mat b(N,vec(1));
b[1][0]=1;
b=mul(a,b);
cout<<b[n][0]<<endl;
return 0;
}
sugarrr