# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
305869 | couplefire | Boat (APIO16_boat) | C++17 | 11 ms | 4480 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 503;
const int p = 1000000007;
int l[N], a[N], b[N], H[N << 1], cnt = 0, n, f[N][N << 1], ni[N];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf("%d%d", a + i, b + i);
H[++cnt] = a[i];
H[++cnt] = ++b[i];
}
stable_sort(H + 1, H + cnt + 1);
cnt = unique(H + 1, H + cnt + 1) - H;
for (int i = 1; i <= n; ++i) {
a[i] = lower_bound(H + 1, H + cnt, a[i]) - H;
b[i] = lower_bound(H + 1, H + cnt, b[i]) - H;
}
cnt -= 2;
for (int i = 1; i <= cnt; ++i)
l[i] = H[i + 1] - H[i];
ni[1] = 1;
for (int i = 2; i <= n; ++i)
ni[i] = 1ll * (p - p / i) * ni[p % i] % p;
for (int i = 0; i <= cnt; ++i) f[0][i] = 1;
for (int i = 1; i <= n; ++i) {
for (int j = a[i], up = b[i]; j < up; ++j) {
int C = l[j], r = l[j], c = 1;
for (int k = i - 1; k >= 0; --k) {
(f[i][j] += 1ll * f[k][j - 1] * C % p) %= p;
if (a[k] <= j && j < b[k]) {
++r; ++c;
C = 1ll * C * r % p * ni[c] % p;
}
}
}
for (int j = 2; j <= cnt; ++j)
(f[i][j] += f[i][j - 1]) %= p;
}
int ans = 0;
for (int i = 1; i <= n; ++i) (ans += f[i][cnt]) %= p;
printf("%d\n", ans);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |