# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1258896 | khanhdangiuu | Boat (APIO16_boat) | C++20 | 1 ms | 328 KiB |
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pi 3.14159265358979323846
#define pb push_back
#define ar array
template<typename T, typename cmp = std::greater<T>>
using pq = priority_queue<T, vector<T>, cmp>;
template<typename T, typename cmp = std::less<T>>
using ordered_set = tree<T, __gnu_pbds::null_type, cmp, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
void chay()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#define task "Hi"
freopen(task".INP", "r", stdin);
freopen(task".OUT", "w", stdout);
}
const int N = 500, INF = numeric_limits<int>::max();
const int block = 600;
const long long INFLL = numeric_limits<ll>::max();
long long M = 1e9+7;
int n, a[N+5], b[N+5];
namespace sub1
{
bool check()
{
bool ok = true;
for (int i = 1; i <= n; i++)
{
if (a[i] != b[i]) ok = false;
}
return n <= 500 && ok;
}
int dp[N+5];
void solve()
{
dp[0] = 1;
a[n+1] = INF;
for (int i = 1; i <= n; i++)
{
for (int j = 0; j < i; j++)
{
if (a[i] > a[j]) dp[i] += dp[j];
if (dp[i] >= M) dp[i] -= M;
}
}
int tong = 0;
for (int i = 1; i <= n; i++)
{
tong += dp[i];
if (tong >= M) tong -= M;
}
cout<<tong;
}
}
void solve()
{
cin>>n;
for (int i = 1; i <= n; i++) cin>>a[i]>>b[i];
if (sub1::check()) sub1::solve();
}
signed main ()
{
//chay();
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
//cin>>t;
while (t--)
{
solve();
}
return 0;
}
Compilation message (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... |