結果

問題 No.801 エレベーター
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2019-03-17 22:13:42
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 583 ms / 2,000 ms
コード長 1,795 bytes
コンパイル時間 1,047 ms
コンパイル使用メモリ 90,880 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 07:10:02
合計ジャッジ時間 11,306 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 11 ms
4,376 KB
testcase_04 AC 12 ms
4,376 KB
testcase_05 AC 11 ms
4,376 KB
testcase_06 AC 12 ms
4,380 KB
testcase_07 AC 11 ms
4,376 KB
testcase_08 AC 11 ms
4,376 KB
testcase_09 AC 11 ms
4,376 KB
testcase_10 AC 11 ms
4,380 KB
testcase_11 AC 11 ms
4,380 KB
testcase_12 AC 12 ms
4,376 KB
testcase_13 AC 581 ms
4,376 KB
testcase_14 AC 579 ms
4,376 KB
testcase_15 AC 579 ms
4,380 KB
testcase_16 AC 578 ms
4,380 KB
testcase_17 AC 580 ms
4,376 KB
testcase_18 AC 578 ms
4,380 KB
testcase_19 AC 578 ms
4,376 KB
testcase_20 AC 581 ms
4,376 KB
testcase_21 AC 583 ms
4,380 KB
testcase_22 AC 582 ms
4,376 KB
testcase_23 AC 535 ms
4,380 KB
testcase_24 AC 531 ms
4,376 KB
testcase_25 AC 532 ms
4,376 KB
testcase_26 AC 529 ms
4,376 KB
testcase_27 AC 532 ms
4,376 KB
testcase_28 AC 440 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define endl "\n"
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

#define N_MAX 3010

struct bit{
  long long dat[N_MAX + 1];

  void init(){
    for(int i = 0; i < N_MAX; i++){
      dat[i] = 0;
    }
  }

  long long sum(int i){
  	if(i==0)return 0;
    long long s = 0;
    while(i > 0){
      s += dat[i];
      s %= MOD;
      i -= i & -i;
    }
    return s;
  }

  void add(int i, long long x){
    while(i <= N_MAX){
      dat[i] += x;
      dat[i] %= MOD;
      i += i & -i;
    }
  }
}bit1;

ll d[3010];

int main(){
	ll n,m,k;
	cin>>n>>m>>k;
	vector<pair<ll,ll> > vp;
	rep(i,0,m){
		ll a,b;
		cin>>a>>b;
		vp.pb(mp(a,b));
	}
	bit1.init();
	bit1.add(1,1);
	rep(K,0,k){
		clr(d,0);
		rep(i,0,vp.sz){
			ll l = vp[i].fi;
			ll r = vp[i].se;
			ll sum = (bit1.sum(r)+MOD)-bit1.sum(l-1);
			sum %= MOD;
			d[l] += sum;
			d[l] %= MOD;
			d[r+1] += MOD;
			d[r+1] -= sum;
			d[r+1] %= MOD;
		}
		rep(i,1,3005){
			d[i] += d[i-1];
			d[i] %= MOD;
		}
		bit1.init();
		rep(i,1,n+1){
			bit1.add(i,d[i]);
		}
	}
	cout << (bit1.sum(n)+MOD-bit1.sum(n-1))%MOD << endl;
	return 0;	
}
0