# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
66197 |
2018-08-10T04:01:45 Z |
박상수(#2151) |
초음속철도 (OJUZ11_rail) |
C++11 |
|
710 ms |
142728 KB |
#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
ll m, n, two[200005], sz;
pair<ll,ll> a[200005];
vector<ll> cpr;
struct segtree {
ll val[1111111], lazy[1111111];
void lazydown (ll P) {
val[2*P] = (val[2*P] * two[lazy[P]]) % mod;
lazy[2*P] += lazy[P];
val[2*P+1] = (val[2*P+1] * two[lazy[P]]) % mod;
lazy[2*P+1] += lazy[P];
lazy[P] = 0;
}
void pl (ll SS, ll SE, ll X, ll P, ll V) {
if(SE < X || X < SS) return;
if(SS == SE) {val[P] += V; return;}
lazydown(P);
ll mid = (SS+SE)/2;
pl(SS, mid, X, 2*P, V);
pl(mid+1, SE, X, 2*P+1, V);
val[P] = (val[2*P] + val[2*P+1]) % mod;
}
void pl(ll X, ll V) {pl(0, sz-1, X, 1, V);}
void ml (ll SS, ll SE, ll S, ll E, ll P, ll V) {
if(S <= SS && SE <= E) {
val[P] = (val[P] * two[V]) % mod;
lazy[P] += V;
return;
}
if(SE < S || E < SS) return;
lazydown(P);
ll mid = (SS+SE)/2;
ml(SS, mid, S, E, 2*P, V);
ml(mid+1, SE, S, E, 2*P+1, V);
val[P] = (val[2*P] + val[2*P+1]) % mod;
}
void ml (ll S, ll E, ll V) {ml(0, sz-1, S, E, 1, V);}
ll query (ll SS, ll SE, ll S, ll E, ll P) {
if(S <= SS && SE <= E) return val[P];
if(SE < S || E < SS) return 0;
lazydown(P);
ll mid = (SS+SE)/2;
return (query(SS, mid, S, E, 2*P) +
query(mid+1, SE, S, E, 2*P+1)) % mod;
}
ll query (ll S, ll E) {return query(0, sz-1, S, E, 1);}
} seg;
int main()
{
scanf("%lld%lld",&m,&n);
two[0] = 1;
for(int i=1;i<=n;i++) {
two[i] = (two[i-1] * 2) % mod;
}
for(int i=1;i<=n;i++) {
scanf("%lld%lld",&a[i].X,&a[i].Y);
cpr.push_back(a[i].X);
cpr.push_back(a[i].Y);
}
sort(cpr.begin(), cpr.end());
cpr.erase(unique(cpr.begin(), cpr.end()), cpr.end());
if(cpr[0] != 1 || cpr.back() != m) {puts("0"); return 0;}
for(int i=1;i<=n;i++) {
a[i].X = lower_bound(cpr.begin(), cpr.end(), a[i].X) - cpr.begin();
a[i].Y = lower_bound(cpr.begin(), cpr.end(), a[i].Y) - cpr.begin();
}
sort(a+1, a+1+n);
sz = cpr.size();
seg.pl(0, 1);
for(int i=1;i<=n;i++) {
seg.pl(a[i].Y, seg.query(a[i].X, a[i].Y));
seg.ml(a[i].Y+1, sz-1, 1);
}
printf("%lld\n",seg.query(sz-1, sz-1));
}
Compilation message
rail.cpp: In function 'int main()':
rail.cpp:58:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld%lld",&m,&n);
~~~~~^~~~~~~~~~~~~~~~~~
rail.cpp:64:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld%lld",&a[i].X,&a[i].Y);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
492 KB |
Output is correct |
3 |
Correct |
2 ms |
492 KB |
Output is correct |
4 |
Correct |
28 ms |
628 KB |
Output is correct |
5 |
Correct |
2 ms |
628 KB |
Output is correct |
6 |
Correct |
3 ms |
628 KB |
Output is correct |
7 |
Correct |
2 ms |
632 KB |
Output is correct |
8 |
Correct |
2 ms |
632 KB |
Output is correct |
9 |
Correct |
2 ms |
728 KB |
Output is correct |
10 |
Correct |
2 ms |
756 KB |
Output is correct |
11 |
Correct |
2 ms |
764 KB |
Output is correct |
12 |
Correct |
2 ms |
764 KB |
Output is correct |
13 |
Correct |
2 ms |
768 KB |
Output is correct |
14 |
Correct |
3 ms |
772 KB |
Output is correct |
15 |
Correct |
3 ms |
776 KB |
Output is correct |
16 |
Correct |
2 ms |
816 KB |
Output is correct |
17 |
Correct |
3 ms |
820 KB |
Output is correct |
18 |
Correct |
2 ms |
824 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
492 KB |
Output is correct |
3 |
Correct |
2 ms |
492 KB |
Output is correct |
4 |
Correct |
28 ms |
628 KB |
Output is correct |
5 |
Correct |
2 ms |
628 KB |
Output is correct |
6 |
Correct |
3 ms |
628 KB |
Output is correct |
7 |
Correct |
2 ms |
632 KB |
Output is correct |
8 |
Correct |
2 ms |
632 KB |
Output is correct |
9 |
Correct |
2 ms |
728 KB |
Output is correct |
10 |
Correct |
2 ms |
756 KB |
Output is correct |
11 |
Correct |
2 ms |
764 KB |
Output is correct |
12 |
Correct |
2 ms |
764 KB |
Output is correct |
13 |
Correct |
2 ms |
768 KB |
Output is correct |
14 |
Correct |
3 ms |
772 KB |
Output is correct |
15 |
Correct |
3 ms |
776 KB |
Output is correct |
16 |
Correct |
2 ms |
816 KB |
Output is correct |
17 |
Correct |
3 ms |
820 KB |
Output is correct |
18 |
Correct |
2 ms |
824 KB |
Output is correct |
19 |
Correct |
2 ms |
828 KB |
Output is correct |
20 |
Correct |
3 ms |
828 KB |
Output is correct |
21 |
Correct |
2 ms |
836 KB |
Output is correct |
22 |
Correct |
2 ms |
840 KB |
Output is correct |
23 |
Correct |
2 ms |
864 KB |
Output is correct |
24 |
Correct |
3 ms |
868 KB |
Output is correct |
25 |
Correct |
3 ms |
868 KB |
Output is correct |
26 |
Correct |
2 ms |
876 KB |
Output is correct |
27 |
Correct |
3 ms |
876 KB |
Output is correct |
28 |
Correct |
3 ms |
884 KB |
Output is correct |
29 |
Correct |
3 ms |
888 KB |
Output is correct |
30 |
Correct |
2 ms |
892 KB |
Output is correct |
31 |
Correct |
2 ms |
896 KB |
Output is correct |
32 |
Correct |
3 ms |
900 KB |
Output is correct |
33 |
Correct |
2 ms |
900 KB |
Output is correct |
34 |
Correct |
2 ms |
908 KB |
Output is correct |
35 |
Correct |
3 ms |
908 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1044 KB |
Output is correct |
2 |
Correct |
2 ms |
1044 KB |
Output is correct |
3 |
Correct |
3 ms |
1044 KB |
Output is correct |
4 |
Correct |
9 ms |
1432 KB |
Output is correct |
5 |
Correct |
271 ms |
15224 KB |
Output is correct |
6 |
Correct |
490 ms |
33480 KB |
Output is correct |
7 |
Correct |
523 ms |
36280 KB |
Output is correct |
8 |
Correct |
3 ms |
36280 KB |
Output is correct |
9 |
Correct |
457 ms |
39156 KB |
Output is correct |
10 |
Correct |
493 ms |
43324 KB |
Output is correct |
11 |
Correct |
175 ms |
43324 KB |
Output is correct |
12 |
Correct |
483 ms |
48608 KB |
Output is correct |
13 |
Correct |
445 ms |
52348 KB |
Output is correct |
14 |
Correct |
93 ms |
52348 KB |
Output is correct |
15 |
Correct |
429 ms |
52348 KB |
Output is correct |
16 |
Correct |
98 ms |
52348 KB |
Output is correct |
17 |
Correct |
453 ms |
66000 KB |
Output is correct |
18 |
Correct |
486 ms |
69820 KB |
Output is correct |
19 |
Correct |
477 ms |
73740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
492 KB |
Output is correct |
3 |
Correct |
2 ms |
492 KB |
Output is correct |
4 |
Correct |
28 ms |
628 KB |
Output is correct |
5 |
Correct |
2 ms |
628 KB |
Output is correct |
6 |
Correct |
3 ms |
628 KB |
Output is correct |
7 |
Correct |
2 ms |
632 KB |
Output is correct |
8 |
Correct |
2 ms |
632 KB |
Output is correct |
9 |
Correct |
2 ms |
728 KB |
Output is correct |
10 |
Correct |
2 ms |
756 KB |
Output is correct |
11 |
Correct |
2 ms |
764 KB |
Output is correct |
12 |
Correct |
2 ms |
764 KB |
Output is correct |
13 |
Correct |
2 ms |
768 KB |
Output is correct |
14 |
Correct |
3 ms |
772 KB |
Output is correct |
15 |
Correct |
3 ms |
776 KB |
Output is correct |
16 |
Correct |
2 ms |
816 KB |
Output is correct |
17 |
Correct |
3 ms |
820 KB |
Output is correct |
18 |
Correct |
2 ms |
824 KB |
Output is correct |
19 |
Correct |
2 ms |
828 KB |
Output is correct |
20 |
Correct |
3 ms |
828 KB |
Output is correct |
21 |
Correct |
2 ms |
836 KB |
Output is correct |
22 |
Correct |
2 ms |
840 KB |
Output is correct |
23 |
Correct |
2 ms |
864 KB |
Output is correct |
24 |
Correct |
3 ms |
868 KB |
Output is correct |
25 |
Correct |
3 ms |
868 KB |
Output is correct |
26 |
Correct |
2 ms |
876 KB |
Output is correct |
27 |
Correct |
3 ms |
876 KB |
Output is correct |
28 |
Correct |
3 ms |
884 KB |
Output is correct |
29 |
Correct |
3 ms |
888 KB |
Output is correct |
30 |
Correct |
2 ms |
892 KB |
Output is correct |
31 |
Correct |
2 ms |
896 KB |
Output is correct |
32 |
Correct |
3 ms |
900 KB |
Output is correct |
33 |
Correct |
2 ms |
900 KB |
Output is correct |
34 |
Correct |
2 ms |
908 KB |
Output is correct |
35 |
Correct |
3 ms |
908 KB |
Output is correct |
36 |
Correct |
18 ms |
73740 KB |
Output is correct |
37 |
Correct |
10 ms |
73740 KB |
Output is correct |
38 |
Correct |
10 ms |
73740 KB |
Output is correct |
39 |
Correct |
4 ms |
73740 KB |
Output is correct |
40 |
Correct |
12 ms |
73740 KB |
Output is correct |
41 |
Correct |
7 ms |
73740 KB |
Output is correct |
42 |
Correct |
14 ms |
73740 KB |
Output is correct |
43 |
Correct |
2 ms |
73740 KB |
Output is correct |
44 |
Correct |
13 ms |
73740 KB |
Output is correct |
45 |
Correct |
4 ms |
73740 KB |
Output is correct |
46 |
Correct |
9 ms |
73740 KB |
Output is correct |
47 |
Correct |
11 ms |
73740 KB |
Output is correct |
48 |
Correct |
13 ms |
73740 KB |
Output is correct |
49 |
Correct |
6 ms |
73740 KB |
Output is correct |
50 |
Correct |
7 ms |
73740 KB |
Output is correct |
51 |
Correct |
7 ms |
73740 KB |
Output is correct |
52 |
Correct |
5 ms |
73740 KB |
Output is correct |
53 |
Correct |
6 ms |
73740 KB |
Output is correct |
54 |
Correct |
8 ms |
73740 KB |
Output is correct |
55 |
Correct |
6 ms |
73740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
492 KB |
Output is correct |
3 |
Correct |
2 ms |
492 KB |
Output is correct |
4 |
Correct |
28 ms |
628 KB |
Output is correct |
5 |
Correct |
2 ms |
628 KB |
Output is correct |
6 |
Correct |
3 ms |
628 KB |
Output is correct |
7 |
Correct |
2 ms |
632 KB |
Output is correct |
8 |
Correct |
2 ms |
632 KB |
Output is correct |
9 |
Correct |
2 ms |
728 KB |
Output is correct |
10 |
Correct |
2 ms |
756 KB |
Output is correct |
11 |
Correct |
2 ms |
764 KB |
Output is correct |
12 |
Correct |
2 ms |
764 KB |
Output is correct |
13 |
Correct |
2 ms |
768 KB |
Output is correct |
14 |
Correct |
3 ms |
772 KB |
Output is correct |
15 |
Correct |
3 ms |
776 KB |
Output is correct |
16 |
Correct |
2 ms |
816 KB |
Output is correct |
17 |
Correct |
3 ms |
820 KB |
Output is correct |
18 |
Correct |
2 ms |
824 KB |
Output is correct |
19 |
Correct |
2 ms |
828 KB |
Output is correct |
20 |
Correct |
3 ms |
828 KB |
Output is correct |
21 |
Correct |
2 ms |
836 KB |
Output is correct |
22 |
Correct |
2 ms |
840 KB |
Output is correct |
23 |
Correct |
2 ms |
864 KB |
Output is correct |
24 |
Correct |
3 ms |
868 KB |
Output is correct |
25 |
Correct |
3 ms |
868 KB |
Output is correct |
26 |
Correct |
2 ms |
876 KB |
Output is correct |
27 |
Correct |
3 ms |
876 KB |
Output is correct |
28 |
Correct |
3 ms |
884 KB |
Output is correct |
29 |
Correct |
3 ms |
888 KB |
Output is correct |
30 |
Correct |
2 ms |
892 KB |
Output is correct |
31 |
Correct |
2 ms |
896 KB |
Output is correct |
32 |
Correct |
3 ms |
900 KB |
Output is correct |
33 |
Correct |
2 ms |
900 KB |
Output is correct |
34 |
Correct |
2 ms |
908 KB |
Output is correct |
35 |
Correct |
3 ms |
908 KB |
Output is correct |
36 |
Correct |
3 ms |
1044 KB |
Output is correct |
37 |
Correct |
2 ms |
1044 KB |
Output is correct |
38 |
Correct |
3 ms |
1044 KB |
Output is correct |
39 |
Correct |
9 ms |
1432 KB |
Output is correct |
40 |
Correct |
271 ms |
15224 KB |
Output is correct |
41 |
Correct |
490 ms |
33480 KB |
Output is correct |
42 |
Correct |
523 ms |
36280 KB |
Output is correct |
43 |
Correct |
3 ms |
36280 KB |
Output is correct |
44 |
Correct |
457 ms |
39156 KB |
Output is correct |
45 |
Correct |
493 ms |
43324 KB |
Output is correct |
46 |
Correct |
175 ms |
43324 KB |
Output is correct |
47 |
Correct |
483 ms |
48608 KB |
Output is correct |
48 |
Correct |
445 ms |
52348 KB |
Output is correct |
49 |
Correct |
93 ms |
52348 KB |
Output is correct |
50 |
Correct |
429 ms |
52348 KB |
Output is correct |
51 |
Correct |
98 ms |
52348 KB |
Output is correct |
52 |
Correct |
453 ms |
66000 KB |
Output is correct |
53 |
Correct |
486 ms |
69820 KB |
Output is correct |
54 |
Correct |
477 ms |
73740 KB |
Output is correct |
55 |
Correct |
18 ms |
73740 KB |
Output is correct |
56 |
Correct |
10 ms |
73740 KB |
Output is correct |
57 |
Correct |
10 ms |
73740 KB |
Output is correct |
58 |
Correct |
4 ms |
73740 KB |
Output is correct |
59 |
Correct |
12 ms |
73740 KB |
Output is correct |
60 |
Correct |
7 ms |
73740 KB |
Output is correct |
61 |
Correct |
14 ms |
73740 KB |
Output is correct |
62 |
Correct |
2 ms |
73740 KB |
Output is correct |
63 |
Correct |
13 ms |
73740 KB |
Output is correct |
64 |
Correct |
4 ms |
73740 KB |
Output is correct |
65 |
Correct |
9 ms |
73740 KB |
Output is correct |
66 |
Correct |
11 ms |
73740 KB |
Output is correct |
67 |
Correct |
13 ms |
73740 KB |
Output is correct |
68 |
Correct |
6 ms |
73740 KB |
Output is correct |
69 |
Correct |
7 ms |
73740 KB |
Output is correct |
70 |
Correct |
7 ms |
73740 KB |
Output is correct |
71 |
Correct |
5 ms |
73740 KB |
Output is correct |
72 |
Correct |
6 ms |
73740 KB |
Output is correct |
73 |
Correct |
8 ms |
73740 KB |
Output is correct |
74 |
Correct |
6 ms |
73740 KB |
Output is correct |
75 |
Correct |
710 ms |
79172 KB |
Output is correct |
76 |
Correct |
413 ms |
79172 KB |
Output is correct |
77 |
Correct |
294 ms |
79172 KB |
Output is correct |
78 |
Correct |
93 ms |
79172 KB |
Output is correct |
79 |
Correct |
118 ms |
79172 KB |
Output is correct |
80 |
Correct |
669 ms |
91092 KB |
Output is correct |
81 |
Correct |
14 ms |
91092 KB |
Output is correct |
82 |
Correct |
637 ms |
94392 KB |
Output is correct |
83 |
Correct |
88 ms |
94392 KB |
Output is correct |
84 |
Correct |
527 ms |
100724 KB |
Output is correct |
85 |
Correct |
564 ms |
100724 KB |
Output is correct |
86 |
Correct |
614 ms |
100724 KB |
Output is correct |
87 |
Correct |
177 ms |
100724 KB |
Output is correct |
88 |
Correct |
174 ms |
100724 KB |
Output is correct |
89 |
Correct |
657 ms |
120176 KB |
Output is correct |
90 |
Correct |
670 ms |
123920 KB |
Output is correct |
91 |
Correct |
662 ms |
127784 KB |
Output is correct |
92 |
Correct |
120 ms |
127784 KB |
Output is correct |
93 |
Correct |
564 ms |
127784 KB |
Output is correct |
94 |
Correct |
626 ms |
138968 KB |
Output is correct |
95 |
Correct |
698 ms |
142728 KB |
Output is correct |