結果

問題 No.801 エレベーター
ユーザー SHIJOUSHIJOU
提出日時 2020-08-15 19:59:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 431 ms / 2,000 ms
コード長 2,864 bytes
コンパイル時間 2,216 ms
コンパイル使用メモリ 199,740 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-01 05:21:57
合計ジャッジ時間 10,117 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 5 ms
4,380 KB
testcase_04 AC 5 ms
4,380 KB
testcase_05 AC 6 ms
4,376 KB
testcase_06 AC 5 ms
4,376 KB
testcase_07 AC 5 ms
4,376 KB
testcase_08 AC 5 ms
4,376 KB
testcase_09 AC 6 ms
4,380 KB
testcase_10 AC 5 ms
4,380 KB
testcase_11 AC 5 ms
4,376 KB
testcase_12 AC 6 ms
4,380 KB
testcase_13 AC 431 ms
4,384 KB
testcase_14 AC 429 ms
4,380 KB
testcase_15 AC 425 ms
4,376 KB
testcase_16 AC 426 ms
4,380 KB
testcase_17 AC 427 ms
4,376 KB
testcase_18 AC 431 ms
4,376 KB
testcase_19 AC 429 ms
4,380 KB
testcase_20 AC 431 ms
4,384 KB
testcase_21 AC 428 ms
4,376 KB
testcase_22 AC 430 ms
4,380 KB
testcase_23 AC 405 ms
4,376 KB
testcase_24 AC 400 ms
4,380 KB
testcase_25 AC 400 ms
4,376 KB
testcase_26 AC 399 ms
4,376 KB
testcase_27 AC 403 ms
4,380 KB
testcase_28 AC 225 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
  int64_t x;
  mint(int64_t x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(int64_t t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  //for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

const int N = 3010;

//head

int n, m, k;
int l[N], r[N];
mint bit[2][N];
mint X[N];
int now = 1;
void add(int i, mint x, int w) {
  while(i <= n) {
    bit[w][i] += x;
    i += i&-i;
  }
}
inline void add(int i, int x, int w) {add(i, mint(x), w);}
mint sum(int i, int w) {
  mint res;
  while(i) {
    res += bit[w][i];
    i &= i-1;
  }
  return res;
}


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> k;
  rep(i, m) cin >> l[i] >> r[i];

  add(1, 1, 0);
  rep(i, k) {
    int pre = now^1;
    memset(bit[now], 0, sizeof(bit[0]));
    memset(X, 0, sizeof(X));
    rep(j, m) {
      mint ss = sum(r[j], pre) - sum(l[j]-1, pre);
      X[l[j]-1] += ss;
      X[r[j]] -= ss;
    }
    rep(j, n) {
      X[j+1] += X[j];
      add(j+1, X[j], now);
    }
    now ^= 1;
  }

  cout << X[n-1] << endl;
}
0