結果
| 問題 |
No.801 エレベーター
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-03-18 08:45:56 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,330 bytes |
| コンパイル時間 | 1,444 ms |
| コンパイル使用メモリ | 162,660 KB |
| 実行使用メモリ | 82,212 KB |
| 最終ジャッジ日時 | 2024-07-17 13:07:02 |
| 合計ジャッジ時間 | 6,182 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 TLE * 1 -- * 15 |
ソースコード
#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;
}