# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
20579 | 2017-02-12T12:46:39 Z | G(#74, gs12117) | 초음속철도 (OJUZ11_rail) | C++11 | 1829 ms | 62272 KB |
#include<cstdio> #include<algorithm> #include<set> #include<map> #include<vector> 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; std::vector<int> bneed; void itrefresh(int loc) { if (itrt[loc] == itqn)return; itrt[loc] = itqn; bneed.push_back(loc); 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 itbuild(int loc) { if (loc < itsz) { it[loc] = it[loc * 2] * itmult[loc * 2] + it[loc * 2 + 1] * itmult[loc * 2 + 1]; it[loc] %= mod; } } void itb() { for (int i : bneed) { itbuild(i); } } void itpush(int loc, int val) { itqn++; bneed.clear(); loc += itsz; itrefresh(loc); it[loc] += val; it[loc] %= mod; itb(); } 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++; bneed.clear(); 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); start++; } if (end % 2 == 0) { itrefresh(end); end--; } start /= 2; end /= 2; } itb(); } 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
# | 결과 | 실행 시간 | 메모리 | 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 |
# | 결과 | 실행 시간 | 메모리 | 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 |
# | 결과 | 실행 시간 | 메모리 | 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 | 9 ms | 24916 KB | Output is correct |
5 | Correct | 403 ms | 29932 KB | Output is correct |
6 | Correct | 1059 ms | 59104 KB | Output is correct |
7 | Correct | 1079 ms | 58708 KB | Output is correct |
8 | Correct | 0 ms | 24784 KB | Output is correct |
9 | Correct | 966 ms | 56596 KB | Output is correct |
10 | Correct | 993 ms | 58312 KB | Output is correct |
11 | Correct | 343 ms | 27952 KB | Output is correct |
12 | Correct | 1079 ms | 59104 KB | Output is correct |
13 | Correct | 1153 ms | 58576 KB | Output is correct |
14 | Correct | 296 ms | 24784 KB | Output is correct |
15 | Correct | 933 ms | 43528 KB | Output is correct |
16 | Correct | 316 ms | 24784 KB | Output is correct |
17 | Correct | 1103 ms | 59236 KB | Output is correct |
18 | Correct | 1116 ms | 59104 KB | Output is correct |
19 | Correct | 1049 ms | 54220 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | 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 | 19 ms | 25708 KB | Output is correct |
37 | Correct | 13 ms | 25576 KB | Output is correct |
38 | Correct | 13 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 | 13 ms | 25708 KB | Output is correct |
42 | Correct | 19 ms | 25708 KB | Output is correct |
43 | Correct | 0 ms | 24784 KB | Output is correct |
44 | Correct | 16 ms | 25444 KB | Output is correct |
45 | Correct | 3 ms | 24784 KB | Output is correct |
46 | Correct | 9 ms | 25312 KB | Output is correct |
47 | Correct | 16 ms | 25312 KB | Output is correct |
48 | Correct | 13 ms | 25312 KB | Output is correct |
49 | Correct | 6 ms | 24784 KB | Output is correct |
50 | Correct | 6 ms | 24784 KB | Output is correct |
51 | Correct | 6 ms | 24784 KB | Output is correct |
52 | Correct | 3 ms | 25048 KB | Output is correct |
53 | Correct | 16 ms | 25708 KB | Output is correct |
54 | Correct | 6 ms | 25048 KB | Output is correct |
55 | Correct | 13 ms | 25708 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | 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 | 9 ms | 24916 KB | Output is correct |
40 | Correct | 403 ms | 29932 KB | Output is correct |
41 | Correct | 1059 ms | 59104 KB | Output is correct |
42 | Correct | 1079 ms | 58708 KB | Output is correct |
43 | Correct | 0 ms | 24784 KB | Output is correct |
44 | Correct | 966 ms | 56596 KB | Output is correct |
45 | Correct | 993 ms | 58312 KB | Output is correct |
46 | Correct | 343 ms | 27952 KB | Output is correct |
47 | Correct | 1079 ms | 59104 KB | Output is correct |
48 | Correct | 1153 ms | 58576 KB | Output is correct |
49 | Correct | 296 ms | 24784 KB | Output is correct |
50 | Correct | 933 ms | 43528 KB | Output is correct |
51 | Correct | 316 ms | 24784 KB | Output is correct |
52 | Correct | 1103 ms | 59236 KB | Output is correct |
53 | Correct | 1116 ms | 59104 KB | Output is correct |
54 | Correct | 1049 ms | 54220 KB | Output is correct |
55 | Correct | 19 ms | 25708 KB | Output is correct |
56 | Correct | 13 ms | 25576 KB | Output is correct |
57 | Correct | 13 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 | 13 ms | 25708 KB | Output is correct |
61 | Correct | 19 ms | 25708 KB | Output is correct |
62 | Correct | 0 ms | 24784 KB | Output is correct |
63 | Correct | 16 ms | 25444 KB | Output is correct |
64 | Correct | 3 ms | 24784 KB | Output is correct |
65 | Correct | 9 ms | 25312 KB | Output is correct |
66 | Correct | 16 ms | 25312 KB | Output is correct |
67 | Correct | 13 ms | 25312 KB | Output is correct |
68 | Correct | 6 ms | 24784 KB | Output is correct |
69 | Correct | 6 ms | 24784 KB | Output is correct |
70 | Correct | 6 ms | 24784 KB | Output is correct |
71 | Correct | 3 ms | 25048 KB | Output is correct |
72 | Correct | 16 ms | 25708 KB | Output is correct |
73 | Correct | 6 ms | 25048 KB | Output is correct |
74 | Correct | 13 ms | 25708 KB | Output is correct |
75 | Correct | 1696 ms | 62272 KB | Output is correct |
76 | Correct | 989 ms | 49336 KB | Output is correct |
77 | Correct | 503 ms | 25048 KB | Output is correct |
78 | Correct | 269 ms | 24784 KB | Output is correct |
79 | Correct | 829 ms | 31912 KB | Output is correct |
80 | Correct | 1716 ms | 62272 KB | Output is correct |
81 | Correct | 16 ms | 25180 KB | Output is correct |
82 | Correct | 1556 ms | 58180 KB | Output is correct |
83 | Correct | 236 ms | 24784 KB | Output is correct |
84 | Correct | 1333 ms | 52900 KB | Output is correct |
85 | Correct | 1203 ms | 43528 KB | Output is correct |
86 | Correct | 1259 ms | 43528 KB | Output is correct |
87 | Correct | 356 ms | 24784 KB | Output is correct |
88 | Correct | 369 ms | 24784 KB | Output is correct |
89 | Correct | 1683 ms | 62272 KB | Output is correct |
90 | Correct | 1829 ms | 62272 KB | Output is correct |
91 | Correct | 1743 ms | 62272 KB | Output is correct |
92 | Correct | 1639 ms | 61216 KB | Output is correct |
93 | Correct | 1306 ms | 43528 KB | Output is correct |
94 | Correct | 1763 ms | 62272 KB | Output is correct |
95 | Correct | 1713 ms | 62272 KB | Output is correct |