結果

問題 No.801 エレベーター
ユーザー addeight2addeight2
提出日時 2019-03-18 20:50:41
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,454 bytes
コンパイル時間 1,218 ms
コンパイル使用メモリ 144,632 KB
実行使用メモリ 7,924 KB
最終ジャッジ日時 2023-09-26 08:39:25
合計ジャッジ時間 5,430 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
7,756 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 39 ms
4,380 KB
testcase_04 AC 40 ms
4,384 KB
testcase_05 AC 39 ms
4,380 KB
testcase_06 AC 39 ms
4,384 KB
testcase_07 AC 40 ms
4,384 KB
testcase_08 AC 41 ms
4,380 KB
testcase_09 AC 39 ms
4,384 KB
testcase_10 AC 40 ms
4,384 KB
testcase_11 AC 39 ms
4,380 KB
testcase_12 AC 40 ms
4,380 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];
		if(seg[k]>=MOD){
			seg[k]-=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];
			if(psm[j+1]>=MOD){
				psm[j+1]-=MOD;
			}
		}
		REP(j,M){
			ll x=psm[R[j]]-psm[L[j]];
			if(x<0){
				x+=MOD;
			}
			add(L[j],R[j],x,0,0,n2);
		}
		int w=n2,a=0,k=0;
		while(w>0){
			if(a==n2){
				a=0;
				w>>=1;
				continue;
			}
			lazpro(k++,a,a+w);
			a+=w;
		}
		REP(j,N){
			dp[j]=seg[n2-1+j];
		}
	}
	printf("%lld\n",dp[N-1]);
}
0