# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
158270 | maruii | Boat (APIO16_boat) | C++14 | 11 ms | 4348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
vector<int> xx(1);
int f[505][1005], s[1005], g[505][1005], A[505], B[505];
int main() {
ios_base::sync_with_stdio(0), cin.tie(0);
int N; cin >> N;
for (int i = 1; i <= N; ++i) {
cin >> A[i] >> B[i]; B[i]++;
xx.push_back(A[i]);
xx.push_back(B[i]);
}
sort(xx.begin(), xx.end());
xx.erase(unique(xx.begin(), xx.end()), xx.end());
for (int i = 1; i <= N; ++i) {
s[0] = f[i - 1][0] = 1;
for (int j = 1; j + 1 < xx.size(); ++j) s[j] = (s[j - 1] + f[i - 1][j]) % mod;
for (int j = 1; j + 1 < xx.size(); ++j) {
if (A[i] <= xx[j] && xx[j + 1] <= B[i]) {
long long n = xx[j + 1] - xx[j];
f[i][j] = (n * s[j - 1] + g[i - 1][j]) % mod;
g[i][j] = ((n + 1) * n / 2 % mod * s[j - 1] % mod + g[i - 1][j] * n % mod - n * (n - 1) / 2 % mod * f[i - 1][j] % mod + mod) % mod;
}
else {
f[i][j] = f[i - 1][j];
g[i][j] = g[i - 1][j];
}
}
}
int ans = 0;
for (int i = 0; i + 1 < xx.size(); ++i) ans = (ans + f[N][i]) % mod;
cout << 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... |