# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
278533 | 2020-08-21T13:58:11 Z | BeanZ | Boat (APIO16_boat) | C++14 | 6 ms | 4608 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' ll dp[505][505], inv[2005], l[505], r[505]; const int mod = 1e9 + 7; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); if (fopen("VietCT.INP", "r")){ freopen("VietCT.INP", "r", stdin); freopen("VietCT.OUT", "w", stdout); } ll n; cin >> n; inv[1] = 1; for (int i = 2; i < 2000; i++) inv[i] = (mod / i) * (mod - inv[mod % i]) % mod; vector<ll> val; for (int i = 1; i <= n; i++){ cin >> l[i] >> r[i]; val.push_back(l[i]); r[i]++; val.push_back(r[i]); } sort(val.begin(), val.end()); val.resize(unique(val.begin(), val.end()) - val.begin()); for (int i = 1; i <= n; i++){ l[i] = lower_bound(val.begin(), val.end(), l[i]) - val.begin() + 1; r[i] = lower_bound(val.begin(), val.end(), r[i]) - val.begin() + 1; } dp[0][0] = 1; for (int i = 1; i < val.size(); i++){ dp[i][0] = 1; for (int j = 1; j <= n; j++){ dp[i][j] = dp[i - 1][j]; if (i < l[j] || i >= r[j]) continue; ll s = val[i] - val[i - 1]; ll cnt = 1; ll p = s; for (int k = j - 1; k >= 0; k--){ dp[i][j] = (dp[i][j] + dp[i - 1][k] * p) % mod; p = p * (s + cnt) % mod; p = p * inv[cnt + 1] % mod; cnt++; } } } ll ans = 0; for (int i = 1; i <= n; i++){ ans = (ans + dp[val.size() - 1][i]) % mod; } cout << ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 6 ms | 4608 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 6 ms | 4608 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 1152 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 6 ms | 4608 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |