結果

問題 No.801 エレベーター
ユーザー satou_a_man
提出日時 2019-03-18 08:47:49
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 199 ms / 2,000 ms
コード長 958 bytes
コンパイル時間 2,233 ms
コンパイル使用メモリ 196,604 KB
最終ジャッジ日時 2025-01-06 23:21:29
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

ll dp[3000+2][3000+2];
const ll p=1e9+7;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n,m,K;
  cin>>n>>m>>K;
  vector<int> l(m);
  vector<int> r(m);
  rep(i,m)cin>>l[i]>>r[i];
  memset(dp,0,sizeof(dp));
  dp[0][1]=1;
  repeat(k,1,K+1) {
    vector<ll> acc(n+1);
    repeat(x,1,n+1) {
      acc[x]+=acc[x-1]+dp[k-1][x];
      acc[x]%=p;
    }
    rep(i,m) {
      ll s=(acc[r[i]]-acc[l[i]-1]+p)%p;
      // imos
      dp[k][l[i]]+=s;
      dp[k][l[i]]%=p;
      dp[k][r[i]+1]+=(p-s);
      dp[k][r[i]+1]%=p;
    }
    repeat(x,1,n+2) {
      dp[k][x]+=dp[k][x-1];
      dp[k][x]%=p;
    }
  }
  cout << dp[K][n] << endl;
  return 0;
}
0