結果

問題 No.801 エレベーター
ユーザー ThistleThistle
提出日時 2019-03-29 20:04:19
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 3,045 bytes
コンパイル時間 1,045 ms
コンパイル使用メモリ 116,488 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 16:43:27
合計ジャッジ時間 3,572 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 101 ms
5,376 KB
testcase_14 AC 102 ms
5,376 KB
testcase_15 AC 102 ms
5,376 KB
testcase_16 AC 101 ms
5,376 KB
testcase_17 AC 101 ms
5,376 KB
testcase_18 AC 107 ms
5,376 KB
testcase_19 AC 114 ms
5,376 KB
testcase_20 AC 103 ms
5,376 KB
testcase_21 AC 102 ms
5,376 KB
testcase_22 AC 99 ms
5,376 KB
testcase_23 AC 98 ms
5,376 KB
testcase_24 AC 98 ms
5,376 KB
testcase_25 AC 97 ms
5,376 KB
testcase_26 AC 99 ms
5,376 KB
testcase_27 AC 100 ms
5,376 KB
testcase_28 AC 105 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
h = "";
i = j + 1;
	}
	return vec;
}
template<typename T>
void print_vec(vector<T>a) {
	for (int i = 0; i < a.size(); i++) {
		cout << (i == 0 ? "" : " ") << a[i];
	}
	cout << endl;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n, m, k;
H a[10000];
int dp[10000];
//j回の移動の後でi階にたどり着く通り数
int b[10000];
//累積和
signed main() {
	cin >> n >> m >> k;
	for (int i = 0; i < m; i++) {
		cin >> a[i].x >> a[i].y;
		a[i].x--; a[i].y--;
	}
	dp[0] = 1;
	for (int i = 0; i < k; i++) {
		for (int j = 0; j < n; j++) {
			b[j] = (j == 0 ? 0 : b[j - 1]);
			b[j] += dp[j];
			b[j] %= Mod;
			dp[j] = 0;
		}
		for (int j = 0; j < m; j++) {
			int k = b[a[j].y] - (a[j].x == 0 ? 0 : b[a[j].x - 1]);
			dp[a[j].x] += k;
			dp[a[j].y + 1] -= k;
		}
		for (int j = 1; j < n; j++) {
			dp[j] += dp[j - 1];
			dp[j] %= Mod;
		}
	}
	cout << (dp[n - 1] + Mod) % Mod << endl;
}
0