# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
501356 | Abrar_Al_Samit | Boat (APIO16_boat) | C++17 | 2077 ms | 8240 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int MX = 505;
const int Mod = 1e9 + 7;
int a[MX], b[MX];
map<pair<int,int>,int>dp;
int n;
int solve(int i, int prev) {
if(i>n) return (prev!=0);
if(dp.count(make_pair(i, prev))) return dp[make_pair(i, prev)];
int ret = 0;
ret = solve(i+1, prev);
for(int cur=max(a[i], prev+1); cur<=b[i]; ++cur) {
ret += solve(i+1, cur);
if(ret>=Mod) ret -= Mod;
}
return dp[make_pair(i, prev)] = ret;
}
void PlayGround() {
cin >> n;
for(int i=1; i<=n; ++i) {
cin >> a[i] >> b[i];
}
cout << solve(1, 0) << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
PlayGround();
# | 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... |