結果

問題 No.801 エレベーター
ユーザー goodbatongoodbaton
提出日時 2019-03-17 21:42:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,613 bytes
コンパイル時間 1,816 ms
コンパイル使用メモリ 119,152 KB
実行使用メモリ 8,136 KB
最終ジャッジ日時 2023-09-22 04:39:09
合計ジャッジ時間 5,976 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,136 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 40 ms
4,380 KB
testcase_04 AC 40 ms
4,380 KB
testcase_05 AC 40 ms
4,380 KB
testcase_06 AC 39 ms
4,380 KB
testcase_07 AC 40 ms
4,376 KB
testcase_08 AC 41 ms
4,380 KB
testcase_09 AC 38 ms
4,384 KB
testcase_10 AC 40 ms
4,376 KB
testcase_11 AC 39 ms
4,376 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 <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 3010

/* Starry Sky Tree */
//0-index

struct StarrySkyTree{
  typedef ll Type;
  int segn2;
  vector<Type> data, s_data;
  function<Type(Type, Type)> merge;

  StarrySkyTree(function<Type(Type, Type)> merge, int n): merge(merge)
  {
    for(segn2=1; segn2<n; segn2*=2);
    data.assign(segn2*2, 0);
    s_data.assign(segn2*2, 0);
  }

  StarrySkyTree(int n): //Original Ver.
    StarrySkyTree([](Type a, Type b){ return a + b; }, n) {}

  //get value of [a,b)
  Type query(int a, int b, int l = 0, int r = -1, int k = 0){
    if(r == -1) r = segn2;
    if(r <= a || b <= l) return 0; //大きさに注意
    if(a <= l && r <= b) return data[k] + s_data[k] * (r - l);
    return merge(query(a, b, l, (l+r)/2, k*2+1), query(a, b, (l+r)/2 , r, k*2+2)) + s_data[k] * (min(b, r) - max(a, l));
  }

  //add x to [a,b)
  Type add(int a, int b, Type x, int l = 0, int r = -1, int k = 0){
    if(r == -1) r = segn2;
    if(a <= l && r <= b)
      s_data[k] += x;
    else if(a < r && l < b)
      data[k] = merge(add(a, b, x, l, (l+r)/2, k*2+1), add(a, b, x, (l+r)/2, r, k*2+2));

    return data[k] + s_data[k] * (r - l);
  }

};



int main(){
  int N, M, K;
  pair<int,int> ele[SIZE];

  cin >> N >> M >> K;

  for(int i=0;i<M;i++){
    int l, r;
    cin >> l >> r;
    ele[i] = {l-1, r-1};
  }

  sort(ele, ele + M);

  StarrySkyTree seg(N);

  seg.add(0, 1, 1);

  for(int i=0;i<K;i++){
    StarrySkyTree seg2(N);

    for(int j=0;j<M;j++){
      ll p = seg.query(ele[j].first, ele[j].second+1);
      seg2.add(ele[j].first, ele[j].second+1, p%mod);
    }

    seg = seg2;
  }

  cout << seg.query(N-1, N) % mod << endl;

  return 0;
}
0