結果

問題 No.801 エレベーター
ユーザー satou_a_mansatou_a_man
提出日時 2019-03-18 08:45:56
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,330 bytes
コンパイル時間 2,585 ms
コンパイル使用メモリ 148,304 KB
実行使用メモリ 81,428 KB
最終ジャッジ日時 2023-09-24 12:13:18
合計ジャッジ時間 7,696 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
78,884 KB
testcase_01 AC 21 ms
74,512 KB
testcase_02 AC 21 ms
74,636 KB
testcase_03 AC 58 ms
81,188 KB
testcase_04 AC 59 ms
81,428 KB
testcase_05 AC 56 ms
81,240 KB
testcase_06 AC 58 ms
81,256 KB
testcase_07 AC 59 ms
81,156 KB
testcase_08 AC 59 ms
81,208 KB
testcase_09 AC 57 ms
81,252 KB
testcase_10 AC 58 ms
81,184 KB
testcase_11 AC 57 ms
81,160 KB
testcase_12 AC 57 ms
81,192 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 <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];
ll c[3000+1][3000+1];
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];
  repeat(x,1,n+1) {
    repeat(y,1,n+1) {
      ll tc=0;
      rep(i,m) {
        if(l[i]<=x&&x<=r[i]&&l[i]<=y&&y<=r[i])
          tc++;
      }
      c[x][y]=tc%p;
    }
  }
  memset(dp,0,sizeof(dp));
  dp[0][1]=1;
  // repeat(kk,1,k+1) {
  //   repeat(x,1,n+1) {
  //     repeat(y,1,n+1) {
  //       dp[kk][x]+=(dp[kk-1][y]*c[x][y])%p;
  //       dp[kk][x]%=p;
  //     }
  //   }
  // }
  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