# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
20577 | 2017-02-12T12:35:06 Z | G(#74, gs12117) | 초음속철도 (OJUZ11_rail) | C++11 | 2029 ms | 62272 KB |
#include<cstdio> #include<algorithm> #include<set> #include<map> int n, m; const int mod = 1000000007; const int itsz = 1 << 19; int inp[200100][2]; struct train { int s, e; bool operator<(const train&r)const { return s < r.s; } }; train tl[200100]; long long int it[itsz * 2]; long long int itmult[itsz * 2]; int itrt[itsz * 2]; int itqn; void itrefresh(int loc) { if (itrt[loc] == itqn)return; itrt[loc] = itqn; if (loc != 1)itrefresh(loc / 2); it[loc] *= itmult[loc]; it[loc] %= mod; if (loc < itsz) { itmult[loc * 2] *= itmult[loc]; itmult[loc * 2] %= mod; itmult[loc * 2 + 1] *= itmult[loc]; itmult[loc * 2 + 1] %= mod; } itmult[loc] = 1; } void itbuildup(int loc) { if (loc < itsz) { it[loc] = it[loc * 2] * itmult[loc * 2] + it[loc * 2 + 1] * itmult[loc * 2 + 1]; it[loc] %= mod; } if (loc != 1)itbuildup(loc / 2); } void itpush(int loc, int val) { itqn++; loc += itsz; itrefresh(loc); it[loc] += val; it[loc] %= mod; itbuildup(loc); } int itcalc(int start, int end) { start += itsz; end += itsz; long long int res = 0; while (start <= end) { if (start % 2 == 1) { itrefresh(start); res += it[start]; res %= mod; start++; } if (end % 2 == 0) { itrefresh(end); res += it[end]; res %= mod; end--; } start /= 2; end /= 2; } return res; } void itdouble(int start, int end) { int ts, te; itqn++; start += itsz; end += itsz; ts = start; te = end; while (start <= end) { if (start % 2 == 1) { itmult[start] *= 2; itmult[start] %= mod; start++; } if (end % 2 == 0) { itmult[end] *= 2; itmult[end] %= mod; end--; } start /= 2; end /= 2; } start = ts; end = te; while (start <= end) { if (start % 2 == 1) { itrefresh(start); itbuildup(start); start++; } if (end % 2 == 0) { itrefresh(end); itbuildup(end); end--; } start /= 2; end /= 2; } } int main() { scanf("%d%d", &n, &m); for (int i = 0; i < m; i++) { scanf("%d%d", &inp[i][0], &inp[i][1]); } std::set<int> sp; std::map<int, int> mp; for (int i = 0; i < m; i++) { sp.insert(inp[i][0]); sp.insert(inp[i][1]); } sp.insert(1); sp.insert(n); int cnt = 0; for (auto &i : sp) { cnt++; mp[i] = cnt; } for (int i = 0; i < m; i++) { tl[i].s = mp[inp[i][0]]; tl[i].e = mp[inp[i][1]]; } std::sort(tl, tl + m); itpush(1, 1); for (int i = 0; i < m; i++) { itpush(tl[i].e, itcalc(tl[i].s, tl[i].e)); itdouble(tl[i].e + 1, cnt); } printf("%d", itcalc(cnt, cnt)); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 24784 KB | Output is correct |
2 | Correct | 0 ms | 24784 KB | Output is correct |
3 | Correct | 0 ms | 24784 KB | Output is correct |
4 | Correct | 0 ms | 24784 KB | Output is correct |
5 | Correct | 0 ms | 24784 KB | Output is correct |
6 | Correct | 0 ms | 24784 KB | Output is correct |
7 | Correct | 0 ms | 24784 KB | Output is correct |
8 | Correct | 0 ms | 24784 KB | Output is correct |
9 | Correct | 0 ms | 24784 KB | Output is correct |
10 | Correct | 0 ms | 24784 KB | Output is correct |
11 | Correct | 0 ms | 24784 KB | Output is correct |
12 | Correct | 0 ms | 24784 KB | Output is correct |
13 | Correct | 0 ms | 24784 KB | Output is correct |
14 | Correct | 0 ms | 24784 KB | Output is correct |
15 | Correct | 0 ms | 24784 KB | Output is correct |
16 | Correct | 0 ms | 24784 KB | Output is correct |
17 | Correct | 0 ms | 24784 KB | Output is correct |
18 | Correct | 0 ms | 24784 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 24784 KB | Output is correct |
2 | Correct | 0 ms | 24784 KB | Output is correct |
3 | Correct | 0 ms | 24784 KB | Output is correct |
4 | Correct | 0 ms | 24784 KB | Output is correct |
5 | Correct | 0 ms | 24784 KB | Output is correct |
6 | Correct | 0 ms | 24784 KB | Output is correct |
7 | Correct | 0 ms | 24784 KB | Output is correct |
8 | Correct | 0 ms | 24784 KB | Output is correct |
9 | Correct | 0 ms | 24784 KB | Output is correct |
10 | Correct | 0 ms | 24784 KB | Output is correct |
11 | Correct | 0 ms | 24784 KB | Output is correct |
12 | Correct | 0 ms | 24784 KB | Output is correct |
13 | Correct | 0 ms | 24784 KB | Output is correct |
14 | Correct | 0 ms | 24784 KB | Output is correct |
15 | Correct | 0 ms | 24784 KB | Output is correct |
16 | Correct | 0 ms | 24784 KB | Output is correct |
17 | Correct | 0 ms | 24784 KB | Output is correct |
18 | Correct | 0 ms | 24784 KB | Output is correct |
19 | Correct | 0 ms | 24784 KB | Output is correct |
20 | Correct | 0 ms | 24784 KB | Output is correct |
21 | Correct | 0 ms | 24784 KB | Output is correct |
22 | Correct | 0 ms | 24784 KB | Output is correct |
23 | Correct | 0 ms | 24784 KB | Output is correct |
24 | Correct | 0 ms | 24784 KB | Output is correct |
25 | Correct | 0 ms | 24784 KB | Output is correct |
26 | Correct | 0 ms | 24784 KB | Output is correct |
27 | Correct | 0 ms | 24784 KB | Output is correct |
28 | Correct | 0 ms | 24784 KB | Output is correct |
29 | Correct | 0 ms | 24784 KB | Output is correct |
30 | Correct | 0 ms | 24784 KB | Output is correct |
31 | Correct | 0 ms | 24784 KB | Output is correct |
32 | Correct | 0 ms | 24784 KB | Output is correct |
33 | Correct | 0 ms | 24784 KB | Output is correct |
34 | Correct | 0 ms | 24784 KB | Output is correct |
35 | Correct | 0 ms | 24784 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 24784 KB | Output is correct |
2 | Correct | 0 ms | 24784 KB | Output is correct |
3 | Correct | 0 ms | 24784 KB | Output is correct |
4 | Correct | 13 ms | 24916 KB | Output is correct |
5 | Correct | 453 ms | 29932 KB | Output is correct |
6 | Correct | 1299 ms | 59104 KB | Output is correct |
7 | Correct | 1316 ms | 58708 KB | Output is correct |
8 | Correct | 0 ms | 24784 KB | Output is correct |
9 | Correct | 1176 ms | 56596 KB | Output is correct |
10 | Correct | 1239 ms | 58312 KB | Output is correct |
11 | Correct | 479 ms | 27952 KB | Output is correct |
12 | Correct | 1313 ms | 59104 KB | Output is correct |
13 | Correct | 1409 ms | 58576 KB | Output is correct |
14 | Correct | 306 ms | 24784 KB | Output is correct |
15 | Correct | 1096 ms | 43528 KB | Output is correct |
16 | Correct | 333 ms | 24784 KB | Output is correct |
17 | Correct | 1363 ms | 59236 KB | Output is correct |
18 | Correct | 1333 ms | 59104 KB | Output is correct |
19 | Correct | 1236 ms | 54220 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 24784 KB | Output is correct |
2 | Correct | 0 ms | 24784 KB | Output is correct |
3 | Correct | 0 ms | 24784 KB | Output is correct |
4 | Correct | 0 ms | 24784 KB | Output is correct |
5 | Correct | 0 ms | 24784 KB | Output is correct |
6 | Correct | 0 ms | 24784 KB | Output is correct |
7 | Correct | 0 ms | 24784 KB | Output is correct |
8 | Correct | 0 ms | 24784 KB | Output is correct |
9 | Correct | 0 ms | 24784 KB | Output is correct |
10 | Correct | 0 ms | 24784 KB | Output is correct |
11 | Correct | 0 ms | 24784 KB | Output is correct |
12 | Correct | 0 ms | 24784 KB | Output is correct |
13 | Correct | 0 ms | 24784 KB | Output is correct |
14 | Correct | 0 ms | 24784 KB | Output is correct |
15 | Correct | 0 ms | 24784 KB | Output is correct |
16 | Correct | 0 ms | 24784 KB | Output is correct |
17 | Correct | 0 ms | 24784 KB | Output is correct |
18 | Correct | 0 ms | 24784 KB | Output is correct |
19 | Correct | 0 ms | 24784 KB | Output is correct |
20 | Correct | 0 ms | 24784 KB | Output is correct |
21 | Correct | 0 ms | 24784 KB | Output is correct |
22 | Correct | 0 ms | 24784 KB | Output is correct |
23 | Correct | 0 ms | 24784 KB | Output is correct |
24 | Correct | 0 ms | 24784 KB | Output is correct |
25 | Correct | 0 ms | 24784 KB | Output is correct |
26 | Correct | 0 ms | 24784 KB | Output is correct |
27 | Correct | 0 ms | 24784 KB | Output is correct |
28 | Correct | 0 ms | 24784 KB | Output is correct |
29 | Correct | 0 ms | 24784 KB | Output is correct |
30 | Correct | 0 ms | 24784 KB | Output is correct |
31 | Correct | 0 ms | 24784 KB | Output is correct |
32 | Correct | 0 ms | 24784 KB | Output is correct |
33 | Correct | 0 ms | 24784 KB | Output is correct |
34 | Correct | 0 ms | 24784 KB | Output is correct |
35 | Correct | 0 ms | 24784 KB | Output is correct |
36 | Correct | 23 ms | 25708 KB | Output is correct |
37 | Correct | 19 ms | 25576 KB | Output is correct |
38 | Correct | 16 ms | 25048 KB | Output is correct |
39 | Correct | 6 ms | 24784 KB | Output is correct |
40 | Correct | 13 ms | 25312 KB | Output is correct |
41 | Correct | 19 ms | 25708 KB | Output is correct |
42 | Correct | 23 ms | 25708 KB | Output is correct |
43 | Correct | 0 ms | 24784 KB | Output is correct |
44 | Correct | 23 ms | 25444 KB | Output is correct |
45 | Correct | 6 ms | 24784 KB | Output is correct |
46 | Correct | 13 ms | 25312 KB | Output is correct |
47 | Correct | 19 ms | 25312 KB | Output is correct |
48 | Correct | 16 ms | 25312 KB | Output is correct |
49 | Correct | 9 ms | 24784 KB | Output is correct |
50 | Correct | 9 ms | 24784 KB | Output is correct |
51 | Correct | 9 ms | 24784 KB | Output is correct |
52 | Correct | 0 ms | 25048 KB | Output is correct |
53 | Correct | 23 ms | 25708 KB | Output is correct |
54 | Correct | 9 ms | 25048 KB | Output is correct |
55 | Correct | 23 ms | 25708 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 24784 KB | Output is correct |
2 | Correct | 0 ms | 24784 KB | Output is correct |
3 | Correct | 0 ms | 24784 KB | Output is correct |
4 | Correct | 0 ms | 24784 KB | Output is correct |
5 | Correct | 0 ms | 24784 KB | Output is correct |
6 | Correct | 0 ms | 24784 KB | Output is correct |
7 | Correct | 0 ms | 24784 KB | Output is correct |
8 | Correct | 0 ms | 24784 KB | Output is correct |
9 | Correct | 0 ms | 24784 KB | Output is correct |
10 | Correct | 0 ms | 24784 KB | Output is correct |
11 | Correct | 0 ms | 24784 KB | Output is correct |
12 | Correct | 0 ms | 24784 KB | Output is correct |
13 | Correct | 0 ms | 24784 KB | Output is correct |
14 | Correct | 0 ms | 24784 KB | Output is correct |
15 | Correct | 0 ms | 24784 KB | Output is correct |
16 | Correct | 0 ms | 24784 KB | Output is correct |
17 | Correct | 0 ms | 24784 KB | Output is correct |
18 | Correct | 0 ms | 24784 KB | Output is correct |
19 | Correct | 0 ms | 24784 KB | Output is correct |
20 | Correct | 0 ms | 24784 KB | Output is correct |
21 | Correct | 0 ms | 24784 KB | Output is correct |
22 | Correct | 0 ms | 24784 KB | Output is correct |
23 | Correct | 0 ms | 24784 KB | Output is correct |
24 | Correct | 0 ms | 24784 KB | Output is correct |
25 | Correct | 0 ms | 24784 KB | Output is correct |
26 | Correct | 0 ms | 24784 KB | Output is correct |
27 | Correct | 0 ms | 24784 KB | Output is correct |
28 | Correct | 0 ms | 24784 KB | Output is correct |
29 | Correct | 0 ms | 24784 KB | Output is correct |
30 | Correct | 0 ms | 24784 KB | Output is correct |
31 | Correct | 0 ms | 24784 KB | Output is correct |
32 | Correct | 0 ms | 24784 KB | Output is correct |
33 | Correct | 0 ms | 24784 KB | Output is correct |
34 | Correct | 0 ms | 24784 KB | Output is correct |
35 | Correct | 0 ms | 24784 KB | Output is correct |
36 | Correct | 0 ms | 24784 KB | Output is correct |
37 | Correct | 0 ms | 24784 KB | Output is correct |
38 | Correct | 0 ms | 24784 KB | Output is correct |
39 | Correct | 13 ms | 24916 KB | Output is correct |
40 | Correct | 453 ms | 29932 KB | Output is correct |
41 | Correct | 1299 ms | 59104 KB | Output is correct |
42 | Correct | 1316 ms | 58708 KB | Output is correct |
43 | Correct | 0 ms | 24784 KB | Output is correct |
44 | Correct | 1176 ms | 56596 KB | Output is correct |
45 | Correct | 1239 ms | 58312 KB | Output is correct |
46 | Correct | 479 ms | 27952 KB | Output is correct |
47 | Correct | 1313 ms | 59104 KB | Output is correct |
48 | Correct | 1409 ms | 58576 KB | Output is correct |
49 | Correct | 306 ms | 24784 KB | Output is correct |
50 | Correct | 1096 ms | 43528 KB | Output is correct |
51 | Correct | 333 ms | 24784 KB | Output is correct |
52 | Correct | 1363 ms | 59236 KB | Output is correct |
53 | Correct | 1333 ms | 59104 KB | Output is correct |
54 | Correct | 1236 ms | 54220 KB | Output is correct |
55 | Correct | 23 ms | 25708 KB | Output is correct |
56 | Correct | 19 ms | 25576 KB | Output is correct |
57 | Correct | 16 ms | 25048 KB | Output is correct |
58 | Correct | 6 ms | 24784 KB | Output is correct |
59 | Correct | 13 ms | 25312 KB | Output is correct |
60 | Correct | 19 ms | 25708 KB | Output is correct |
61 | Correct | 23 ms | 25708 KB | Output is correct |
62 | Correct | 0 ms | 24784 KB | Output is correct |
63 | Correct | 23 ms | 25444 KB | Output is correct |
64 | Correct | 6 ms | 24784 KB | Output is correct |
65 | Correct | 13 ms | 25312 KB | Output is correct |
66 | Correct | 19 ms | 25312 KB | Output is correct |
67 | Correct | 16 ms | 25312 KB | Output is correct |
68 | Correct | 9 ms | 24784 KB | Output is correct |
69 | Correct | 9 ms | 24784 KB | Output is correct |
70 | Correct | 9 ms | 24784 KB | Output is correct |
71 | Correct | 0 ms | 25048 KB | Output is correct |
72 | Correct | 23 ms | 25708 KB | Output is correct |
73 | Correct | 9 ms | 25048 KB | Output is correct |
74 | Correct | 23 ms | 25708 KB | Output is correct |
75 | Correct | 1769 ms | 62272 KB | Output is correct |
76 | Correct | 1296 ms | 49336 KB | Output is correct |
77 | Correct | 689 ms | 25048 KB | Output is correct |
78 | Correct | 279 ms | 24784 KB | Output is correct |
79 | Correct | 1099 ms | 31912 KB | Output is correct |
80 | Correct | 1946 ms | 62272 KB | Output is correct |
81 | Correct | 19 ms | 25180 KB | Output is correct |
82 | Correct | 1769 ms | 58180 KB | Output is correct |
83 | Correct | 243 ms | 24784 KB | Output is correct |
84 | Correct | 1529 ms | 52900 KB | Output is correct |
85 | Correct | 1459 ms | 43528 KB | Output is correct |
86 | Correct | 1479 ms | 43528 KB | Output is correct |
87 | Correct | 446 ms | 24784 KB | Output is correct |
88 | Correct | 486 ms | 24784 KB | Output is correct |
89 | Correct | 1826 ms | 62272 KB | Output is correct |
90 | Correct | 2029 ms | 62272 KB | Output is correct |
91 | Correct | 1859 ms | 62272 KB | Output is correct |
92 | Correct | 1816 ms | 61216 KB | Output is correct |
93 | Correct | 1423 ms | 43528 KB | Output is correct |
94 | Correct | 1946 ms | 62272 KB | Output is correct |
95 | Correct | 1933 ms | 62272 KB | Output is correct |