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;
typedef long long ll;
int main() {
const int MOD=1e9+7;
int n; cin>>n;
vector<ll> a(n+1), b(n+1);
for (int i=1; i<=n; i++) {
cin>>a[i]>>b[i];
}
vector<vector<ll>> dp(n+1, vector<ll>(2,0));
dp[1][1]=1;
dp[1][0]=1;
for (int i=2; i<=n; i++) {
for (int j=1; j<i; j++) {
dp[i][0]=(dp[i][0]+dp[j][0]+dp[j][1])%MOD;
dp[i][1]=(dp[i][1]+dp[j][0])%MOD;
if (a[i]>a[j]) {
dp[i][1]=(dp[i][1]+dp[j][1])%MOD;
}
}
}
cout<<(dp[n][1]+dp[n][0])%MOD;
}
# | 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... |