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>
#pragma optimize ("g",on)
#pragma GCC optimize ("inline")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("03")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx2,mmx,fma,avx,tune=native")
//01001101 01100001 01101011 01101000 01100001 01100111 01100001 01111001
using namespace std;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define pb push_back
#define sz(a) a.size()
#define nl '\n'
#define popb pop_back()
#define ld double
#define ull unsigned long long
#define ff first
#define ss second
#define fix fixed << setprecision
#define pii pair<int, int>
#define E exit (0)
#define int long long
const int inf = 1e18, N = 1000001, mod = 1e9 + 7;
double eps = 1e-6;
vector<pii> dir = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
struct node {
node *l, *r;
int sum;
node () {
l = 0, r = 0, sum = 0;
}
};
void update(node *u, int tl, int tr, int pos, int val) {
if (tl == tr) {
u -> sum = (u -> sum + val) % mod;
return;
}
int mid = (tl + tr) / 2;
if (!(u -> l)) u -> l = new node();
if (!(u -> r)) u -> r = new node();
if (pos <= mid) update(u -> l, tl, mid, pos, val);
else update(u -> r, mid + 1, tr, pos, val);
u -> sum = (u -> l -> sum + u -> r -> sum) % mod;
}
int get(node* u, int tl, int tr, int l, int r) {
if (tl > r || tr < l) return 0;
if (tl >= l && tr <= r) return u -> sum;
int mid = (tl + tr) / 2;
int a = 0, b = 0;
if (u -> l) a = get(u -> l, tl, mid, l, r);
if (u -> r) b = get(u -> r, mid + 1, tr, l, r);
return (a + b) % mod;
}
main() {
//freopen("F.in", "r", stdin);
//freopen("F.out", "w", stdout);
ios_base::sync_with_stdio(NULL);
cin.tie(NULL);
int n;
cin >> n;
int a[n + 1], b[n + 1];
for (int i = 1; i <= n; i++) {
cin >> a[i] >> b[i];
}
node *root = new node();
update(root, 0, inf, 0, 1);
for (int i = 1; i <= n; i++) {
for (int cur = b[i]; cur >= a[i]; cur--) {
update(root, 0, inf, cur, get(root, 0, inf, 0, cur - 1));
}
}
cout << get(root, 0, inf, 1, inf);
}
Compilation message (stderr)
boat.cpp:3: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
3 | #pragma optimize ("g",on)
|
boat.cpp:67:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
67 | main() {
| ^~~~
# | 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... |