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;
#define int long long
const int maxn = 502, M_sub2 = 1e6 + 2, MOD = 1e9 + 7;
int n;
pair <int, int> a[maxn];
bool c1, c2, c3;
long long dp[maxn];
long long power(long long a, long long b) {
long long res = 1;
while (b > 0) {
if (b & 1)
res = res * a % MOD;
a = a * a % MOD;
b >>= 1;
}
return res;
}
int mul(int a, int b)
{
return (a * b) % MOD;
}
void sub1()
{
long long ans = 1;
dp[1] = 1;
for (int i = 2; i <= n; i++)
{
dp[i] = 1;
for (int j = 1; j < i; j++)
{
if (a[i].first > a[j].first)
{
// if (i == 2)
// cout << j << ' ' << dp[j] << '\n';
dp[i] += dp[j];
dp[i] %= MOD;
}
}
ans += dp[i];
ans %= MOD;
}
cout << ans;
}
signed main()
{
ios::sync_with_stdio(0); cin.tie(0);
// freopen("input.txt", "r" , stdin);
// freopen("output.txt", "w", stdout);
int sum = 0, tmp = 1e9 + 7;
cin >> n;
for (int i = 1; i <= n; i++)
{
int x, y;
cin >> x >> y;
// if (x != y)
// c1 = 1;
a[i] = {x, y};
}
// if (!c1)
return sub1(), 0;
}
Compilation message (stderr)
boat.cpp: In function 'int main()':
boat.cpp:60:9: warning: unused variable 'sum' [-Wunused-variable]
60 | int sum = 0, tmp = 1e9 + 7;
| ^~~
boat.cpp:60:18: warning: unused variable 'tmp' [-Wunused-variable]
60 | int sum = 0, tmp = 1e9 + 7;
| ^~~
# | 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... |