結果

問題 No.801 エレベーター
ユーザー addeight2addeight2
提出日時 2019-03-18 20:40:22
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,479 bytes
コンパイル時間 2,039 ms
コンパイル使用メモリ 144,456 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-26 07:43:02
合計ジャッジ時間 6,036 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 46 ms
4,376 KB
testcase_04 AC 46 ms
4,376 KB
testcase_05 AC 44 ms
4,376 KB
testcase_06 AC 46 ms
4,380 KB
testcase_07 AC 46 ms
4,376 KB
testcase_08 AC 48 ms
4,376 KB
testcase_09 AC 45 ms
4,376 KB
testcase_10 AC 46 ms
4,380 KB
testcase_11 AC 44 ms
4,380 KB
testcase_12 AC 45 ms
4,376 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>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;
const int MAX_N=3000,MAX_M=3000;
const ll MOD=1e9+7;
int N,M,K,L[MAX_M],R[MAX_M];
int n2;
ll dp[MAX_N],seg[MAX_N<<2],laz[MAX_N<<2],psm[MAX_N+1];
void madd(ll &a,ll b){
	a+=b;
	if(a>=MOD){
		a-=MOD;
	}
}
void lazpro(int k,int a,int b){
	if(laz[k]>0){
		madd(seg[k],laz[k]*(b-a)%MOD);
		if(b-a>1){
			madd(laz[(k<<1)+1],laz[k]);
			madd(laz[(k<<1)+2],laz[k]);
		}
		laz[k]=0;
	}
}
void add(int l,int r,ll x,int k,int a,int b){
	if(r<=a || b<=l){
		return;
	}
	if(l<=a && b<=r){
		madd(laz[k],x);
	}else{
		add(l,r,x,(k<<1)+1,a,(a+b)>>1);
		add(l,r,x,(k<<1)+2,(a+b)>>1,b);
		lazpro(k,a,b);
		lazpro((k<<1)+1,a,(a+b)>>1);
		lazpro((k<<1)+2,(a+b)>>1,b);
		seg[k]=seg[(k<<1)+1]+seg[(k<<1)+2];
		seg[k]%=MOD;
	}
}
ll query(int l,int r,int k,int a,int b){
	if(r<=a || b<=l){
		return 0;
	}
	lazpro(k,a,b);
	if(l<=a && b<=r){
		return seg[k];
	}else{
		return (query(l,r,(k<<1)+1,a,(a+b)>>1)+query(l,r,(k<<1)+2,(a+b)>>1,b))%MOD;
	}
}
		
		
int main(){
	scanf("%d %d %d",&N,&M,&K);
	REP(i,M){
		scanf("%d %d",L+i,R+i);
		L[i]--;
	}
	n2=1;
	while(n2<N) n2<<=1;
	dp[0]=1;
	REP(i,K){
		memset(seg,0,sizeof(seg));
		memset(laz,0,sizeof(laz));
		REP(j,N){
			psm[j+1]=psm[j]+dp[j];
			psm[j+1]%=MOD;
		}
		REP(j,M){
			add(L[j],R[j],(psm[R[j]]-psm[L[j]]+MOD)%MOD,0,0,n2);
		}
		REP(j,N){
			dp[j]=query(j,j+1,0,0,n2);
		}
	}
	printf("%lld\n",dp[N-1]);
}
0