# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
20543 |
2017-02-12T09:15:05 Z |
CodingAmolang(#71, sys7961) |
초음속철도 (OJUZ11_rail) |
C++11 |
|
3000 ms |
22588 KB |
#include<stdio.h>
#include<vector>
#include<algorithm>1
using std::vector;
const long long MOD = 1000000007;
struct indexed_tree {
vector<long long> tree;
int k = 1;
indexed_tree(int n) {
while (k <= n)k *= 2;
tree.resize(k * 3, 0);
}
void update(int idx, int a) {
tree[k + idx] += a;
tree[k + idx] %= MOD;
idx = (k + idx) / 2;
while (idx) {
tree[idx] = (tree[idx * 2] + tree[idx * 2 + 1])%MOD;
idx /= 2;
}
}
long long getSum(int l, int r) {
l += k;
r += k;
long long ret = 0;
while (l <= r) {
if (l % 2 == 1)ret += tree[l];
if (r % 2 == 0)ret += tree[r];
ret %= MOD;
l = (l + 1) / 2;
r = (r - 1) / 2;
}
return ret;
}
};
using std::pair;
int main() {
int n, m;
scanf("%d%d", &n, &m);
vector<long long> X = { 1,n };
vector<pair<long long, long long>> seg;
for (int i = 0; i < m; i++) {
long long s, e;
scanf("%lld%lld", &s, &e);
seg.push_back({ s,e });
X.push_back(s);
X.push_back(e);
}
std::sort(seg.begin(), seg.end());
std::sort(X.begin(), X.end());
X.erase(std::unique(X.begin(), X.end()), X.end());
indexed_tree tree(X.size());
tree.update(0, 1);
for (auto segment : seg) {
long long s = std::lower_bound(X.begin(),X.end(),segment.first)-X.begin();
long long e = std::lower_bound(X.begin(),X.end(),segment.second)-X.begin();
tree.update(e, tree.getSum(s, e));
for (int i = e + 1; i < X.size(); i++) {
tree.update(i, tree.getSum(i, i));
}
}
printf("%lld", tree.getSum(X.size() - 1, X.size() - 1));
}
Compilation message
rail.cpp:3:20: warning: extra tokens at end of #include directive
#include<algorithm>1
^
rail.cpp: In function 'int main()':
rail.cpp:60:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = e + 1; i < X.size(); i++) {
^
rail.cpp:41:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &n, &m);
^
rail.cpp:46:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld%lld", &s, &e);
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1936 KB |
Output is correct |
2 |
Correct |
0 ms |
1936 KB |
Output is correct |
3 |
Correct |
0 ms |
1936 KB |
Output is correct |
4 |
Correct |
0 ms |
1936 KB |
Output is correct |
5 |
Correct |
0 ms |
1936 KB |
Output is correct |
6 |
Correct |
0 ms |
1936 KB |
Output is correct |
7 |
Correct |
0 ms |
1936 KB |
Output is correct |
8 |
Correct |
0 ms |
1936 KB |
Output is correct |
9 |
Correct |
0 ms |
1936 KB |
Output is correct |
10 |
Correct |
0 ms |
1936 KB |
Output is correct |
11 |
Correct |
0 ms |
1936 KB |
Output is correct |
12 |
Correct |
0 ms |
1936 KB |
Output is correct |
13 |
Correct |
0 ms |
1936 KB |
Output is correct |
14 |
Correct |
0 ms |
1936 KB |
Output is correct |
15 |
Correct |
0 ms |
1936 KB |
Output is correct |
16 |
Correct |
0 ms |
1936 KB |
Output is correct |
17 |
Correct |
0 ms |
1936 KB |
Output is correct |
18 |
Correct |
0 ms |
1936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1936 KB |
Output is correct |
2 |
Correct |
0 ms |
1936 KB |
Output is correct |
3 |
Correct |
0 ms |
1936 KB |
Output is correct |
4 |
Correct |
0 ms |
1936 KB |
Output is correct |
5 |
Correct |
0 ms |
1936 KB |
Output is correct |
6 |
Correct |
0 ms |
1936 KB |
Output is correct |
7 |
Correct |
0 ms |
1936 KB |
Output is correct |
8 |
Correct |
0 ms |
1936 KB |
Output is correct |
9 |
Correct |
0 ms |
1936 KB |
Output is correct |
10 |
Correct |
0 ms |
1936 KB |
Output is correct |
11 |
Correct |
0 ms |
1936 KB |
Output is correct |
12 |
Correct |
0 ms |
1936 KB |
Output is correct |
13 |
Correct |
0 ms |
1936 KB |
Output is correct |
14 |
Correct |
0 ms |
1936 KB |
Output is correct |
15 |
Correct |
0 ms |
1936 KB |
Output is correct |
16 |
Correct |
0 ms |
1936 KB |
Output is correct |
17 |
Correct |
0 ms |
1936 KB |
Output is correct |
18 |
Correct |
0 ms |
1936 KB |
Output is correct |
19 |
Correct |
0 ms |
1936 KB |
Output is correct |
20 |
Correct |
0 ms |
1936 KB |
Output is correct |
21 |
Correct |
0 ms |
1936 KB |
Output is correct |
22 |
Correct |
0 ms |
1936 KB |
Output is correct |
23 |
Correct |
0 ms |
1936 KB |
Output is correct |
24 |
Correct |
0 ms |
1936 KB |
Output is correct |
25 |
Correct |
0 ms |
1936 KB |
Output is correct |
26 |
Correct |
0 ms |
1936 KB |
Output is correct |
27 |
Correct |
0 ms |
1936 KB |
Output is correct |
28 |
Correct |
0 ms |
1936 KB |
Output is correct |
29 |
Correct |
0 ms |
1936 KB |
Output is correct |
30 |
Correct |
0 ms |
1936 KB |
Output is correct |
31 |
Correct |
0 ms |
1936 KB |
Output is correct |
32 |
Correct |
0 ms |
1936 KB |
Output is correct |
33 |
Correct |
0 ms |
1936 KB |
Output is correct |
34 |
Correct |
0 ms |
1936 KB |
Output is correct |
35 |
Correct |
0 ms |
1936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1936 KB |
Output is correct |
2 |
Correct |
0 ms |
1936 KB |
Output is correct |
3 |
Correct |
0 ms |
1936 KB |
Output is correct |
4 |
Correct |
179 ms |
2228 KB |
Output is correct |
5 |
Execution timed out |
3000 ms |
12348 KB |
Execution timed out |
6 |
Execution timed out |
3000 ms |
22588 KB |
Execution timed out |
7 |
Execution timed out |
3000 ms |
22588 KB |
Execution timed out |
8 |
Correct |
0 ms |
1936 KB |
Output is correct |
9 |
Execution timed out |
3000 ms |
22588 KB |
Execution timed out |
10 |
Execution timed out |
3000 ms |
22588 KB |
Execution timed out |
11 |
Execution timed out |
3000 ms |
7740 KB |
Execution timed out |
12 |
Execution timed out |
3000 ms |
22588 KB |
Execution timed out |
13 |
Execution timed out |
3000 ms |
22588 KB |
Execution timed out |
14 |
Correct |
79 ms |
12348 KB |
Output is correct |
15 |
Execution timed out |
3000 ms |
16444 KB |
Execution timed out |
16 |
Correct |
83 ms |
12348 KB |
Output is correct |
17 |
Execution timed out |
3000 ms |
22588 KB |
Execution timed out |
18 |
Execution timed out |
3000 ms |
22588 KB |
Execution timed out |
19 |
Execution timed out |
3000 ms |
22588 KB |
Execution timed out |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1936 KB |
Output is correct |
2 |
Correct |
0 ms |
1936 KB |
Output is correct |
3 |
Correct |
0 ms |
1936 KB |
Output is correct |
4 |
Correct |
0 ms |
1936 KB |
Output is correct |
5 |
Correct |
0 ms |
1936 KB |
Output is correct |
6 |
Correct |
0 ms |
1936 KB |
Output is correct |
7 |
Correct |
0 ms |
1936 KB |
Output is correct |
8 |
Correct |
0 ms |
1936 KB |
Output is correct |
9 |
Correct |
0 ms |
1936 KB |
Output is correct |
10 |
Correct |
0 ms |
1936 KB |
Output is correct |
11 |
Correct |
0 ms |
1936 KB |
Output is correct |
12 |
Correct |
0 ms |
1936 KB |
Output is correct |
13 |
Correct |
0 ms |
1936 KB |
Output is correct |
14 |
Correct |
0 ms |
1936 KB |
Output is correct |
15 |
Correct |
0 ms |
1936 KB |
Output is correct |
16 |
Correct |
0 ms |
1936 KB |
Output is correct |
17 |
Correct |
0 ms |
1936 KB |
Output is correct |
18 |
Correct |
0 ms |
1936 KB |
Output is correct |
19 |
Correct |
0 ms |
1936 KB |
Output is correct |
20 |
Correct |
0 ms |
1936 KB |
Output is correct |
21 |
Correct |
0 ms |
1936 KB |
Output is correct |
22 |
Correct |
0 ms |
1936 KB |
Output is correct |
23 |
Correct |
0 ms |
1936 KB |
Output is correct |
24 |
Correct |
0 ms |
1936 KB |
Output is correct |
25 |
Correct |
0 ms |
1936 KB |
Output is correct |
26 |
Correct |
0 ms |
1936 KB |
Output is correct |
27 |
Correct |
0 ms |
1936 KB |
Output is correct |
28 |
Correct |
0 ms |
1936 KB |
Output is correct |
29 |
Correct |
0 ms |
1936 KB |
Output is correct |
30 |
Correct |
0 ms |
1936 KB |
Output is correct |
31 |
Correct |
0 ms |
1936 KB |
Output is correct |
32 |
Correct |
0 ms |
1936 KB |
Output is correct |
33 |
Correct |
0 ms |
1936 KB |
Output is correct |
34 |
Correct |
0 ms |
1936 KB |
Output is correct |
35 |
Correct |
0 ms |
1936 KB |
Output is correct |
36 |
Correct |
1549 ms |
2616 KB |
Output is correct |
37 |
Correct |
973 ms |
2424 KB |
Output is correct |
38 |
Correct |
306 ms |
2228 KB |
Output is correct |
39 |
Correct |
0 ms |
2228 KB |
Output is correct |
40 |
Correct |
1079 ms |
2424 KB |
Output is correct |
41 |
Correct |
1806 ms |
2616 KB |
Output is correct |
42 |
Correct |
1559 ms |
2616 KB |
Output is correct |
43 |
Correct |
0 ms |
1936 KB |
Output is correct |
44 |
Correct |
1223 ms |
2424 KB |
Output is correct |
45 |
Correct |
0 ms |
2228 KB |
Output is correct |
46 |
Correct |
546 ms |
2424 KB |
Output is correct |
47 |
Correct |
719 ms |
2424 KB |
Output is correct |
48 |
Correct |
723 ms |
2424 KB |
Output is correct |
49 |
Correct |
6 ms |
2228 KB |
Output is correct |
50 |
Correct |
3 ms |
2228 KB |
Output is correct |
51 |
Correct |
3 ms |
2228 KB |
Output is correct |
52 |
Correct |
46 ms |
2112 KB |
Output is correct |
53 |
Correct |
1839 ms |
2616 KB |
Output is correct |
54 |
Correct |
243 ms |
2320 KB |
Output is correct |
55 |
Correct |
1593 ms |
2616 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1936 KB |
Output is correct |
2 |
Correct |
0 ms |
1936 KB |
Output is correct |
3 |
Correct |
0 ms |
1936 KB |
Output is correct |
4 |
Correct |
0 ms |
1936 KB |
Output is correct |
5 |
Correct |
0 ms |
1936 KB |
Output is correct |
6 |
Correct |
0 ms |
1936 KB |
Output is correct |
7 |
Correct |
0 ms |
1936 KB |
Output is correct |
8 |
Correct |
0 ms |
1936 KB |
Output is correct |
9 |
Correct |
0 ms |
1936 KB |
Output is correct |
10 |
Correct |
0 ms |
1936 KB |
Output is correct |
11 |
Correct |
0 ms |
1936 KB |
Output is correct |
12 |
Correct |
0 ms |
1936 KB |
Output is correct |
13 |
Correct |
0 ms |
1936 KB |
Output is correct |
14 |
Correct |
0 ms |
1936 KB |
Output is correct |
15 |
Correct |
0 ms |
1936 KB |
Output is correct |
16 |
Correct |
0 ms |
1936 KB |
Output is correct |
17 |
Correct |
0 ms |
1936 KB |
Output is correct |
18 |
Correct |
0 ms |
1936 KB |
Output is correct |
19 |
Correct |
0 ms |
1936 KB |
Output is correct |
20 |
Correct |
0 ms |
1936 KB |
Output is correct |
21 |
Correct |
0 ms |
1936 KB |
Output is correct |
22 |
Correct |
0 ms |
1936 KB |
Output is correct |
23 |
Correct |
0 ms |
1936 KB |
Output is correct |
24 |
Correct |
0 ms |
1936 KB |
Output is correct |
25 |
Correct |
0 ms |
1936 KB |
Output is correct |
26 |
Correct |
0 ms |
1936 KB |
Output is correct |
27 |
Correct |
0 ms |
1936 KB |
Output is correct |
28 |
Correct |
0 ms |
1936 KB |
Output is correct |
29 |
Correct |
0 ms |
1936 KB |
Output is correct |
30 |
Correct |
0 ms |
1936 KB |
Output is correct |
31 |
Correct |
0 ms |
1936 KB |
Output is correct |
32 |
Correct |
0 ms |
1936 KB |
Output is correct |
33 |
Correct |
0 ms |
1936 KB |
Output is correct |
34 |
Correct |
0 ms |
1936 KB |
Output is correct |
35 |
Correct |
0 ms |
1936 KB |
Output is correct |
36 |
Correct |
0 ms |
1936 KB |
Output is correct |
37 |
Correct |
0 ms |
1936 KB |
Output is correct |
38 |
Correct |
0 ms |
1936 KB |
Output is correct |
39 |
Correct |
179 ms |
2228 KB |
Output is correct |
40 |
Execution timed out |
3000 ms |
12348 KB |
Execution timed out |
41 |
Execution timed out |
3000 ms |
22588 KB |
Execution timed out |
42 |
Execution timed out |
3000 ms |
22588 KB |
Execution timed out |
43 |
Correct |
0 ms |
1936 KB |
Output is correct |
44 |
Execution timed out |
3000 ms |
22588 KB |
Execution timed out |
45 |
Execution timed out |
3000 ms |
22588 KB |
Execution timed out |
46 |
Execution timed out |
3000 ms |
7740 KB |
Execution timed out |
47 |
Execution timed out |
3000 ms |
22588 KB |
Execution timed out |
48 |
Execution timed out |
3000 ms |
22588 KB |
Execution timed out |
49 |
Correct |
79 ms |
12348 KB |
Output is correct |
50 |
Execution timed out |
3000 ms |
16444 KB |
Execution timed out |
51 |
Correct |
83 ms |
12348 KB |
Output is correct |
52 |
Execution timed out |
3000 ms |
22588 KB |
Execution timed out |
53 |
Execution timed out |
3000 ms |
22588 KB |
Execution timed out |
54 |
Execution timed out |
3000 ms |
22588 KB |
Execution timed out |
55 |
Correct |
1549 ms |
2616 KB |
Output is correct |
56 |
Correct |
973 ms |
2424 KB |
Output is correct |
57 |
Correct |
306 ms |
2228 KB |
Output is correct |
58 |
Correct |
0 ms |
2228 KB |
Output is correct |
59 |
Correct |
1079 ms |
2424 KB |
Output is correct |
60 |
Correct |
1806 ms |
2616 KB |
Output is correct |
61 |
Correct |
1559 ms |
2616 KB |
Output is correct |
62 |
Correct |
0 ms |
1936 KB |
Output is correct |
63 |
Correct |
1223 ms |
2424 KB |
Output is correct |
64 |
Correct |
0 ms |
2228 KB |
Output is correct |
65 |
Correct |
546 ms |
2424 KB |
Output is correct |
66 |
Correct |
719 ms |
2424 KB |
Output is correct |
67 |
Correct |
723 ms |
2424 KB |
Output is correct |
68 |
Correct |
6 ms |
2228 KB |
Output is correct |
69 |
Correct |
3 ms |
2228 KB |
Output is correct |
70 |
Correct |
3 ms |
2228 KB |
Output is correct |
71 |
Correct |
46 ms |
2112 KB |
Output is correct |
72 |
Correct |
1839 ms |
2616 KB |
Output is correct |
73 |
Correct |
243 ms |
2320 KB |
Output is correct |
74 |
Correct |
1593 ms |
2616 KB |
Output is correct |
75 |
Execution timed out |
3000 ms |
22588 KB |
Execution timed out |
76 |
Execution timed out |
3000 ms |
14396 KB |
Execution timed out |
77 |
Execution timed out |
3000 ms |
12348 KB |
Execution timed out |
78 |
Correct |
63 ms |
12348 KB |
Output is correct |
79 |
Execution timed out |
3000 ms |
13372 KB |
Execution timed out |
80 |
Execution timed out |
3000 ms |
22588 KB |
Execution timed out |
81 |
Correct |
619 ms |
2424 KB |
Output is correct |
82 |
Execution timed out |
3000 ms |
22588 KB |
Execution timed out |
83 |
Correct |
59 ms |
12348 KB |
Output is correct |
84 |
Execution timed out |
3000 ms |
22588 KB |
Execution timed out |
85 |
Execution timed out |
3000 ms |
16444 KB |
Execution timed out |
86 |
Execution timed out |
3000 ms |
16444 KB |
Execution timed out |
87 |
Correct |
183 ms |
12348 KB |
Output is correct |
88 |
Correct |
226 ms |
12348 KB |
Output is correct |
89 |
Execution timed out |
3000 ms |
22588 KB |
Execution timed out |
90 |
Execution timed out |
3000 ms |
22588 KB |
Execution timed out |
91 |
Execution timed out |
3000 ms |
22588 KB |
Execution timed out |
92 |
Execution timed out |
3000 ms |
22588 KB |
Execution timed out |
93 |
Execution timed out |
3000 ms |
16444 KB |
Execution timed out |
94 |
Execution timed out |
3000 ms |
22588 KB |
Execution timed out |
95 |
Execution timed out |
3000 ms |
22588 KB |
Execution timed out |