# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
107864 | Just_Solve_The_Problem | Boat (APIO16_boat) | C++11 | 3 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = (int)507;
const int mod = (int)1e9 + 7;
int add(int a, int b) {
return (a + b) % mod;
}
int mul(int a, int b) {
return (a * 1LL * b) % mod;
}
int n;
vector<int> L, R;
int dp[N];
int pref[2][N];
main() {
scanf("%d", &n);
L.resize(n);
R.resize(n);
for (int i = 0; i < n; i++) {
scanf("%d %d", &L[i], &R[i]);
}
memset(pref, 0, sizeof(pref));
memset(dp, 0, sizeof(dp));
ll ans = 0;
for (int j = 1; j < N; j++) {
if (L[0] <= j && j <= R[0]) {
pref[0][j] = 1;
}
pref[0][j] += pref[0][j - 1];
}
for (int i = 1; i < n; i++) {
for (int j = 1; j < N; j++) {
if (L[i] <= j && j <= R[i]) {
pref[i & 1][j] += pref[(i & 1) ^ 1][j - 1];
if (pref[i & 1][j] >= mod) pref[i & 1][j] -= mod;
dp[j] = pref[i & 1][j];
}
pref[i & 1][j] += pref[i & 1][j - 1];
pref[(i & 1) ^ 1][j - 1] = 0;
}
pref[(i & 1) ^ 1][N - 1] = 0;
}
for (int i = L[n - 1]; i <= R[n - 1]; i++) {
ans += dp[i];
if (ans >= mod) ans -= mod;
}
cout << ans;
}
컴파일 시 표준 에러 (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... |