結果

問題 No.801 エレベーター
ユーザー satou_a_mansatou_a_man
提出日時 2019-03-18 08:47:49
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 188 ms / 2,000 ms
コード長 958 bytes
コンパイル時間 2,242 ms
コンパイル使用メモリ 202,760 KB
実行使用メモリ 74,048 KB
最終ジャッジ日時 2023-09-24 12:14:30
合計ジャッジ時間 6,632 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
73,912 KB
testcase_01 AC 21 ms
73,724 KB
testcase_02 AC 21 ms
73,752 KB
testcase_03 AC 23 ms
74,048 KB
testcase_04 AC 23 ms
73,776 KB
testcase_05 AC 22 ms
73,764 KB
testcase_06 AC 24 ms
73,772 KB
testcase_07 AC 23 ms
73,844 KB
testcase_08 AC 24 ms
73,884 KB
testcase_09 AC 23 ms
73,820 KB
testcase_10 AC 23 ms
73,772 KB
testcase_11 AC 23 ms
73,768 KB
testcase_12 AC 23 ms
73,768 KB
testcase_13 AC 188 ms
73,804 KB
testcase_14 AC 187 ms
73,864 KB
testcase_15 AC 184 ms
73,768 KB
testcase_16 AC 185 ms
73,908 KB
testcase_17 AC 184 ms
73,784 KB
testcase_18 AC 184 ms
73,804 KB
testcase_19 AC 185 ms
73,772 KB
testcase_20 AC 184 ms
73,804 KB
testcase_21 AC 184 ms
73,804 KB
testcase_22 AC 185 ms
73,772 KB
testcase_23 AC 166 ms
73,968 KB
testcase_24 AC 166 ms
73,856 KB
testcase_25 AC 165 ms
73,800 KB
testcase_26 AC 166 ms
73,812 KB
testcase_27 AC 164 ms
73,820 KB
testcase_28 AC 168 ms
73,868 KB
権限があれば一括ダウンロードができます

ソースコード

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