# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
523768 |
2022-02-08T06:37:51 Z |
mansur |
Boat (APIO16_boat) |
C++17 |
|
2000 ms |
113272 KB |
#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
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 |
1 |
Correct |
2 ms |
972 KB |
Output is correct |
2 |
Correct |
2 ms |
972 KB |
Output is correct |
3 |
Correct |
2 ms |
972 KB |
Output is correct |
4 |
Correct |
2 ms |
972 KB |
Output is correct |
5 |
Correct |
2 ms |
972 KB |
Output is correct |
6 |
Correct |
3 ms |
972 KB |
Output is correct |
7 |
Correct |
2 ms |
844 KB |
Output is correct |
8 |
Correct |
2 ms |
844 KB |
Output is correct |
9 |
Correct |
2 ms |
844 KB |
Output is correct |
10 |
Correct |
3 ms |
844 KB |
Output is correct |
11 |
Correct |
2 ms |
972 KB |
Output is correct |
12 |
Correct |
2 ms |
972 KB |
Output is correct |
13 |
Correct |
2 ms |
924 KB |
Output is correct |
14 |
Correct |
2 ms |
972 KB |
Output is correct |
15 |
Correct |
2 ms |
972 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
460 KB |
Output is correct |
18 |
Correct |
1 ms |
460 KB |
Output is correct |
19 |
Correct |
1 ms |
460 KB |
Output is correct |
20 |
Correct |
1 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
972 KB |
Output is correct |
2 |
Correct |
2 ms |
972 KB |
Output is correct |
3 |
Correct |
2 ms |
972 KB |
Output is correct |
4 |
Correct |
2 ms |
972 KB |
Output is correct |
5 |
Correct |
2 ms |
972 KB |
Output is correct |
6 |
Correct |
3 ms |
972 KB |
Output is correct |
7 |
Correct |
2 ms |
844 KB |
Output is correct |
8 |
Correct |
2 ms |
844 KB |
Output is correct |
9 |
Correct |
2 ms |
844 KB |
Output is correct |
10 |
Correct |
3 ms |
844 KB |
Output is correct |
11 |
Correct |
2 ms |
972 KB |
Output is correct |
12 |
Correct |
2 ms |
972 KB |
Output is correct |
13 |
Correct |
2 ms |
924 KB |
Output is correct |
14 |
Correct |
2 ms |
972 KB |
Output is correct |
15 |
Correct |
2 ms |
972 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
460 KB |
Output is correct |
18 |
Correct |
1 ms |
460 KB |
Output is correct |
19 |
Correct |
1 ms |
460 KB |
Output is correct |
20 |
Correct |
1 ms |
460 KB |
Output is correct |
21 |
Correct |
827 ms |
628 KB |
Output is correct |
22 |
Correct |
827 ms |
636 KB |
Output is correct |
23 |
Correct |
766 ms |
760 KB |
Output is correct |
24 |
Correct |
823 ms |
632 KB |
Output is correct |
25 |
Correct |
835 ms |
640 KB |
Output is correct |
26 |
Correct |
883 ms |
648 KB |
Output is correct |
27 |
Correct |
914 ms |
628 KB |
Output is correct |
28 |
Correct |
897 ms |
536 KB |
Output is correct |
29 |
Correct |
993 ms |
564 KB |
Output is correct |
30 |
Correct |
1014 ms |
62132 KB |
Output is correct |
31 |
Correct |
1098 ms |
61116 KB |
Output is correct |
32 |
Correct |
1066 ms |
62340 KB |
Output is correct |
33 |
Correct |
1027 ms |
60624 KB |
Output is correct |
34 |
Correct |
1098 ms |
61200 KB |
Output is correct |
35 |
Correct |
964 ms |
58404 KB |
Output is correct |
36 |
Correct |
968 ms |
60436 KB |
Output is correct |
37 |
Correct |
1002 ms |
61044 KB |
Output is correct |
38 |
Correct |
951 ms |
59072 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2103 ms |
113272 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
972 KB |
Output is correct |
2 |
Correct |
2 ms |
972 KB |
Output is correct |
3 |
Correct |
2 ms |
972 KB |
Output is correct |
4 |
Correct |
2 ms |
972 KB |
Output is correct |
5 |
Correct |
2 ms |
972 KB |
Output is correct |
6 |
Correct |
3 ms |
972 KB |
Output is correct |
7 |
Correct |
2 ms |
844 KB |
Output is correct |
8 |
Correct |
2 ms |
844 KB |
Output is correct |
9 |
Correct |
2 ms |
844 KB |
Output is correct |
10 |
Correct |
3 ms |
844 KB |
Output is correct |
11 |
Correct |
2 ms |
972 KB |
Output is correct |
12 |
Correct |
2 ms |
972 KB |
Output is correct |
13 |
Correct |
2 ms |
924 KB |
Output is correct |
14 |
Correct |
2 ms |
972 KB |
Output is correct |
15 |
Correct |
2 ms |
972 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
460 KB |
Output is correct |
18 |
Correct |
1 ms |
460 KB |
Output is correct |
19 |
Correct |
1 ms |
460 KB |
Output is correct |
20 |
Correct |
1 ms |
460 KB |
Output is correct |
21 |
Correct |
827 ms |
628 KB |
Output is correct |
22 |
Correct |
827 ms |
636 KB |
Output is correct |
23 |
Correct |
766 ms |
760 KB |
Output is correct |
24 |
Correct |
823 ms |
632 KB |
Output is correct |
25 |
Correct |
835 ms |
640 KB |
Output is correct |
26 |
Correct |
883 ms |
648 KB |
Output is correct |
27 |
Correct |
914 ms |
628 KB |
Output is correct |
28 |
Correct |
897 ms |
536 KB |
Output is correct |
29 |
Correct |
993 ms |
564 KB |
Output is correct |
30 |
Correct |
1014 ms |
62132 KB |
Output is correct |
31 |
Correct |
1098 ms |
61116 KB |
Output is correct |
32 |
Correct |
1066 ms |
62340 KB |
Output is correct |
33 |
Correct |
1027 ms |
60624 KB |
Output is correct |
34 |
Correct |
1098 ms |
61200 KB |
Output is correct |
35 |
Correct |
964 ms |
58404 KB |
Output is correct |
36 |
Correct |
968 ms |
60436 KB |
Output is correct |
37 |
Correct |
1002 ms |
61044 KB |
Output is correct |
38 |
Correct |
951 ms |
59072 KB |
Output is correct |
39 |
Execution timed out |
2103 ms |
113272 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |