Submission #66227

# Submission time Handle Problem Language Result Execution time Memory
66227 2018-08-10T05:15:56 Z 강태규(#1885) 초음속철도 (OJUZ11_rail) C++11
45 / 100
614 ms 48240 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

const int mod = 1e9 + 7;
int n, m, k;
pii se[200000];
vector<int> cp;

int find(int x) {
    return lower_bound(cp.begin(), cp.end(), x) - cp.begin() + 1;
}

int seg[1 << 19];
int mul[1 << 19];

void lazy(int i) {
    seg[i << 1] = (llong)seg[i << 1] * mul[i] % mod;
    mul[i << 1] = (llong)mul[i << 1] * mul[i] % mod;
    seg[i << 1 | 1] = (llong)seg[i << 1 | 1] * mul[i] % mod;
    mul[i << 1 | 1] = (llong)mul[i << 1 | 1] * mul[i] % mod;
    mul[i] = 1;
}

void update1(int i, int s, int e, int x, int v) {
    if (s == e) {
        seg[i] = (seg[i] + v) % mod;
        return;
    }
    lazy(i);
    int m = (s + e) / 2;
    if (x <= m) update1(i << 1, s, m, x, v);
    else update1(i << 1 | 1, m + 1, e, x, v);
    seg[i] = (seg[i << 1] + seg[i << 1 | 1]) % mod;
}

void update2(int i, int s, int e, int x, int y) {
    if (e < x || y < s) return;
    if (x <= s && e <= y) {
        seg[i] = (seg[i] << 1) % mod;
        mul[i] = (mul[i] << 1) % mod;
        return;
    }
    lazy(i);
    int m = (s + e) / 2;
    update2(i << 1, s, m, x, y);
    update2(i << 1 | 1, m + 1, e, x, y);
    seg[i] = (seg[i << 1] + seg[i << 1 | 1]) % mod;
}

int query(int i, int s, int e, int x, int y) {
    if (e < x || y < s) return 0;
    if (x <= s && e <= y) return seg[i];
    lazy(i);
    int m = (s + e) / 2;
    int ret = query(i << 1, s, m, x, y);
    ret += query(i << 1 | 1, m + 1, e, x, y);
    return ret % mod;
}

int main() {
    for (int i = 0; i < (1 << 19); ++i) seg[i] = 0, mul[i] = 1;
    
    scanf("%d%d", &n, &m);
    cp.push_back(1);
    cp.push_back(n);
    for (int i = 0; i < m; ++i) {
        scanf("%d%d", &se[i].first, &se[i].second);
        cp.push_back(se[i].first);
        cp.push_back(se[i].second);
    }
    sort(cp.begin(), cp.end());
    cp.erase(unique(cp.begin(), cp.end()), cp.end());
    k = cp.size();
    
    sort(se, se + m);
    update1(1, 1, k, 1, 1);
    
    for (int i = 0; i < m; ++i) {
        int a, b;
        tie(a, b) = se[i];
        a = find(a); b = find(b);
        int ret = query(1, 1, k, a, b);
        update1(1, 1, k, b, ret);
        update2(1, 1, k, b + 1, k);
    }
    printf("%d\n", query(1, 1, k, k, k));
    
	return 0;
}

Compilation message

rail.cpp: In function 'int main()':
rail.cpp:80:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~
rail.cpp:84:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &se[i].first, &se[i].second);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4448 KB Output is correct
2 Correct 6 ms 4456 KB Output is correct
3 Correct 7 ms 4664 KB Output is correct
4 Correct 5 ms 4664 KB Output is correct
5 Correct 6 ms 4664 KB Output is correct
6 Correct 6 ms 4664 KB Output is correct
7 Correct 6 ms 4812 KB Output is correct
8 Correct 6 ms 4812 KB Output is correct
9 Correct 6 ms 4812 KB Output is correct
10 Correct 6 ms 4812 KB Output is correct
11 Correct 6 ms 4812 KB Output is correct
12 Correct 7 ms 4812 KB Output is correct
13 Correct 6 ms 4812 KB Output is correct
14 Correct 6 ms 4812 KB Output is correct
15 Correct 5 ms 4812 KB Output is correct
16 Correct 6 ms 4812 KB Output is correct
17 Correct 7 ms 4812 KB Output is correct
18 Correct 6 ms 4812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4448 KB Output is correct
2 Correct 6 ms 4456 KB Output is correct
3 Correct 7 ms 4664 KB Output is correct
4 Correct 5 ms 4664 KB Output is correct
5 Correct 6 ms 4664 KB Output is correct
6 Correct 6 ms 4664 KB Output is correct
7 Correct 6 ms 4812 KB Output is correct
8 Correct 6 ms 4812 KB Output is correct
9 Correct 6 ms 4812 KB Output is correct
10 Correct 6 ms 4812 KB Output is correct
11 Correct 6 ms 4812 KB Output is correct
12 Correct 7 ms 4812 KB Output is correct
13 Correct 6 ms 4812 KB Output is correct
14 Correct 6 ms 4812 KB Output is correct
15 Correct 5 ms 4812 KB Output is correct
16 Correct 6 ms 4812 KB Output is correct
17 Correct 7 ms 4812 KB Output is correct
18 Correct 6 ms 4812 KB Output is correct
19 Correct 5 ms 4812 KB Output is correct
20 Correct 6 ms 4812 KB Output is correct
21 Correct 6 ms 4812 KB Output is correct
22 Correct 7 ms 4812 KB Output is correct
23 Correct 5 ms 4924 KB Output is correct
24 Correct 7 ms 4928 KB Output is correct
25 Correct 7 ms 4928 KB Output is correct
26 Correct 7 ms 4928 KB Output is correct
27 Correct 6 ms 4928 KB Output is correct
28 Correct 6 ms 4928 KB Output is correct
29 Correct 6 ms 4928 KB Output is correct
30 Correct 7 ms 4928 KB Output is correct
31 Correct 6 ms 4928 KB Output is correct
32 Correct 5 ms 4928 KB Output is correct
33 Correct 8 ms 4928 KB Output is correct
34 Correct 7 ms 4928 KB Output is correct
35 Correct 7 ms 4928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4928 KB Output is correct
2 Correct 8 ms 4928 KB Output is correct
3 Correct 6 ms 4928 KB Output is correct
4 Correct 11 ms 5012 KB Output is correct
5 Correct 291 ms 12208 KB Output is correct
6 Runtime error 394 ms 23816 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 443 ms 26352 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Correct 6 ms 26352 KB Output is correct
9 Runtime error 354 ms 29792 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 429 ms 33604 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Correct 186 ms 33732 KB Output is correct
12 Runtime error 462 ms 38868 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 161 ms 42696 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Correct 104 ms 45288 KB Output is correct
15 Correct 393 ms 47900 KB Output is correct
16 Correct 102 ms 47932 KB Output is correct
17 Runtime error 155 ms 48008 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 289 ms 48028 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 452 ms 48072 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4448 KB Output is correct
2 Correct 6 ms 4456 KB Output is correct
3 Correct 7 ms 4664 KB Output is correct
4 Correct 5 ms 4664 KB Output is correct
5 Correct 6 ms 4664 KB Output is correct
6 Correct 6 ms 4664 KB Output is correct
7 Correct 6 ms 4812 KB Output is correct
8 Correct 6 ms 4812 KB Output is correct
9 Correct 6 ms 4812 KB Output is correct
10 Correct 6 ms 4812 KB Output is correct
11 Correct 6 ms 4812 KB Output is correct
12 Correct 7 ms 4812 KB Output is correct
13 Correct 6 ms 4812 KB Output is correct
14 Correct 6 ms 4812 KB Output is correct
15 Correct 5 ms 4812 KB Output is correct
16 Correct 6 ms 4812 KB Output is correct
17 Correct 7 ms 4812 KB Output is correct
18 Correct 6 ms 4812 KB Output is correct
19 Correct 5 ms 4812 KB Output is correct
20 Correct 6 ms 4812 KB Output is correct
21 Correct 6 ms 4812 KB Output is correct
22 Correct 7 ms 4812 KB Output is correct
23 Correct 5 ms 4924 KB Output is correct
24 Correct 7 ms 4928 KB Output is correct
25 Correct 7 ms 4928 KB Output is correct
26 Correct 7 ms 4928 KB Output is correct
27 Correct 6 ms 4928 KB Output is correct
28 Correct 6 ms 4928 KB Output is correct
29 Correct 6 ms 4928 KB Output is correct
30 Correct 7 ms 4928 KB Output is correct
31 Correct 6 ms 4928 KB Output is correct
32 Correct 5 ms 4928 KB Output is correct
33 Correct 8 ms 4928 KB Output is correct
34 Correct 7 ms 4928 KB Output is correct
35 Correct 7 ms 4928 KB Output is correct
36 Correct 20 ms 48072 KB Output is correct
37 Correct 17 ms 48072 KB Output is correct
38 Correct 13 ms 48072 KB Output is correct
39 Correct 9 ms 48072 KB Output is correct
40 Correct 17 ms 48072 KB Output is correct
41 Correct 20 ms 48072 KB Output is correct
42 Correct 17 ms 48072 KB Output is correct
43 Correct 6 ms 48072 KB Output is correct
44 Correct 14 ms 48072 KB Output is correct
45 Correct 9 ms 48072 KB Output is correct
46 Correct 11 ms 48072 KB Output is correct
47 Correct 20 ms 48072 KB Output is correct
48 Correct 16 ms 48072 KB Output is correct
49 Correct 9 ms 48072 KB Output is correct
50 Correct 13 ms 48072 KB Output is correct
51 Correct 11 ms 48072 KB Output is correct
52 Correct 8 ms 48072 KB Output is correct
53 Correct 19 ms 48072 KB Output is correct
54 Correct 10 ms 48072 KB Output is correct
55 Correct 15 ms 48072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4448 KB Output is correct
2 Correct 6 ms 4456 KB Output is correct
3 Correct 7 ms 4664 KB Output is correct
4 Correct 5 ms 4664 KB Output is correct
5 Correct 6 ms 4664 KB Output is correct
6 Correct 6 ms 4664 KB Output is correct
7 Correct 6 ms 4812 KB Output is correct
8 Correct 6 ms 4812 KB Output is correct
9 Correct 6 ms 4812 KB Output is correct
10 Correct 6 ms 4812 KB Output is correct
11 Correct 6 ms 4812 KB Output is correct
12 Correct 7 ms 4812 KB Output is correct
13 Correct 6 ms 4812 KB Output is correct
14 Correct 6 ms 4812 KB Output is correct
15 Correct 5 ms 4812 KB Output is correct
16 Correct 6 ms 4812 KB Output is correct
17 Correct 7 ms 4812 KB Output is correct
18 Correct 6 ms 4812 KB Output is correct
19 Correct 5 ms 4812 KB Output is correct
20 Correct 6 ms 4812 KB Output is correct
21 Correct 6 ms 4812 KB Output is correct
22 Correct 7 ms 4812 KB Output is correct
23 Correct 5 ms 4924 KB Output is correct
24 Correct 7 ms 4928 KB Output is correct
25 Correct 7 ms 4928 KB Output is correct
26 Correct 7 ms 4928 KB Output is correct
27 Correct 6 ms 4928 KB Output is correct
28 Correct 6 ms 4928 KB Output is correct
29 Correct 6 ms 4928 KB Output is correct
30 Correct 7 ms 4928 KB Output is correct
31 Correct 6 ms 4928 KB Output is correct
32 Correct 5 ms 4928 KB Output is correct
33 Correct 8 ms 4928 KB Output is correct
34 Correct 7 ms 4928 KB Output is correct
35 Correct 7 ms 4928 KB Output is correct
36 Correct 6 ms 4928 KB Output is correct
37 Correct 8 ms 4928 KB Output is correct
38 Correct 6 ms 4928 KB Output is correct
39 Correct 11 ms 5012 KB Output is correct
40 Correct 291 ms 12208 KB Output is correct
41 Runtime error 394 ms 23816 KB Execution killed with signal 11 (could be triggered by violating memory limits)
42 Runtime error 443 ms 26352 KB Execution killed with signal 11 (could be triggered by violating memory limits)
43 Correct 6 ms 26352 KB Output is correct
44 Runtime error 354 ms 29792 KB Execution killed with signal 11 (could be triggered by violating memory limits)
45 Runtime error 429 ms 33604 KB Execution killed with signal 11 (could be triggered by violating memory limits)
46 Correct 186 ms 33732 KB Output is correct
47 Runtime error 462 ms 38868 KB Execution killed with signal 11 (could be triggered by violating memory limits)
48 Runtime error 161 ms 42696 KB Execution killed with signal 11 (could be triggered by violating memory limits)
49 Correct 104 ms 45288 KB Output is correct
50 Correct 393 ms 47900 KB Output is correct
51 Correct 102 ms 47932 KB Output is correct
52 Runtime error 155 ms 48008 KB Execution killed with signal 11 (could be triggered by violating memory limits)
53 Runtime error 289 ms 48028 KB Execution killed with signal 11 (could be triggered by violating memory limits)
54 Runtime error 452 ms 48072 KB Execution killed with signal 11 (could be triggered by violating memory limits)
55 Correct 20 ms 48072 KB Output is correct
56 Correct 17 ms 48072 KB Output is correct
57 Correct 13 ms 48072 KB Output is correct
58 Correct 9 ms 48072 KB Output is correct
59 Correct 17 ms 48072 KB Output is correct
60 Correct 20 ms 48072 KB Output is correct
61 Correct 17 ms 48072 KB Output is correct
62 Correct 6 ms 48072 KB Output is correct
63 Correct 14 ms 48072 KB Output is correct
64 Correct 9 ms 48072 KB Output is correct
65 Correct 11 ms 48072 KB Output is correct
66 Correct 20 ms 48072 KB Output is correct
67 Correct 16 ms 48072 KB Output is correct
68 Correct 9 ms 48072 KB Output is correct
69 Correct 13 ms 48072 KB Output is correct
70 Correct 11 ms 48072 KB Output is correct
71 Correct 8 ms 48072 KB Output is correct
72 Correct 19 ms 48072 KB Output is correct
73 Correct 10 ms 48072 KB Output is correct
74 Correct 15 ms 48072 KB Output is correct
75 Runtime error 476 ms 48176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
76 Correct 379 ms 48176 KB Output is correct
77 Correct 333 ms 48176 KB Output is correct
78 Correct 100 ms 48176 KB Output is correct
79 Correct 464 ms 48176 KB Output is correct
80 Runtime error 157 ms 48176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
81 Correct 16 ms 48176 KB Output is correct
82 Runtime error 152 ms 48176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
83 Correct 78 ms 48176 KB Output is correct
84 Runtime error 450 ms 48176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
85 Correct 512 ms 48176 KB Output is correct
86 Correct 614 ms 48176 KB Output is correct
87 Correct 217 ms 48176 KB Output is correct
88 Correct 178 ms 48176 KB Output is correct
89 Runtime error 516 ms 48240 KB Execution killed with signal 11 (could be triggered by violating memory limits)
90 Runtime error 504 ms 48240 KB Execution killed with signal 11 (could be triggered by violating memory limits)
91 Runtime error 457 ms 48240 KB Execution killed with signal 11 (could be triggered by violating memory limits)
92 Runtime error 434 ms 48240 KB Execution killed with signal 11 (could be triggered by violating memory limits)
93 Correct 544 ms 48240 KB Output is correct
94 Runtime error 164 ms 48240 KB Execution killed with signal 11 (could be triggered by violating memory limits)
95 Runtime error 167 ms 48240 KB Execution killed with signal 11 (could be triggered by violating memory limits)