Submission #339643

# Submission time Handle Problem Language Result Execution time Memory
339643 2020-12-25T18:55:40 Z eyangch Jakarta Skyscrapers (APIO15_skyscraper) C++17
100 / 100
823 ms 248940 KB
#include <bits/stdc++.h>

using namespace std;

struct loc{int x; int doge; int d; bool r;};

int N, M;
int b[30000], p[30000];
vector<int> graph[30000];
int dist[30000];
unordered_set<int> vis;

signed main(){
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        cin >> b[i] >> p[i];
        graph[b[i]].push_back(i);
    }
    fill(dist, dist+N, -1);
    deque<loc> q;
    q.push_back({b[0], 0, 0, true});
    q.push_back({b[0], 0, 0, false});
    vis.reserve(7000000);
    while(!q.empty()){
        if(~dist[b[1]]) break;
        int x = q.front().x, doge = q.front().doge, d = q.front().d;
        bool r = q.front().r;
        q.pop_front();
        if(!(~dist[x])){
            dist[x] = d;
            for(int i : graph[x]){
                q.push_front({x, i, d, true});
                q.push_front({x, i, d, false});
            }
        }
        int dv = p[doge];
        if(!r) dv = -dv;
        x += dv;
        d++;
        int id = x + 30000*p[doge] + 30000*30000*r;
        if(x < 0 || x >= N || vis.find(id) != vis.end()) continue;
        vis.insert(id);
        if((int)vis.size() > 6000000) vis.erase(vis.begin());
        q.push_back({x, doge, d, r});
    }
    cout << dist[b[1]] << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 37 ms 60140 KB Output is correct
2 Correct 38 ms 60088 KB Output is correct
3 Correct 36 ms 60156 KB Output is correct
4 Correct 38 ms 60140 KB Output is correct
5 Correct 38 ms 60140 KB Output is correct
6 Correct 36 ms 60140 KB Output is correct
7 Correct 37 ms 60140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 60140 KB Output is correct
2 Correct 37 ms 60140 KB Output is correct
3 Correct 37 ms 60140 KB Output is correct
4 Correct 39 ms 60140 KB Output is correct
5 Correct 37 ms 60140 KB Output is correct
6 Correct 37 ms 60140 KB Output is correct
7 Correct 36 ms 60140 KB Output is correct
8 Correct 37 ms 60140 KB Output is correct
9 Correct 38 ms 60140 KB Output is correct
10 Correct 37 ms 60140 KB Output is correct
11 Correct 37 ms 60268 KB Output is correct
12 Correct 38 ms 60268 KB Output is correct
13 Correct 38 ms 60268 KB Output is correct
14 Correct 38 ms 60396 KB Output is correct
15 Correct 37 ms 60268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 60140 KB Output is correct
2 Correct 38 ms 60140 KB Output is correct
3 Correct 37 ms 60160 KB Output is correct
4 Correct 38 ms 60140 KB Output is correct
5 Correct 38 ms 60140 KB Output is correct
6 Correct 37 ms 60160 KB Output is correct
7 Correct 37 ms 60140 KB Output is correct
8 Correct 37 ms 60140 KB Output is correct
9 Correct 36 ms 60140 KB Output is correct
10 Correct 37 ms 60140 KB Output is correct
11 Correct 37 ms 60268 KB Output is correct
12 Correct 39 ms 60388 KB Output is correct
13 Correct 38 ms 60268 KB Output is correct
14 Correct 38 ms 60396 KB Output is correct
15 Correct 38 ms 60268 KB Output is correct
16 Correct 38 ms 60268 KB Output is correct
17 Correct 38 ms 60416 KB Output is correct
18 Correct 38 ms 60268 KB Output is correct
19 Correct 38 ms 60268 KB Output is correct
20 Correct 41 ms 60416 KB Output is correct
21 Correct 37 ms 60268 KB Output is correct
22 Correct 37 ms 60268 KB Output is correct
23 Correct 38 ms 60396 KB Output is correct
24 Correct 40 ms 60396 KB Output is correct
25 Correct 38 ms 60268 KB Output is correct
26 Correct 37 ms 60396 KB Output is correct
27 Correct 39 ms 60396 KB Output is correct
28 Correct 40 ms 60908 KB Output is correct
29 Correct 42 ms 62060 KB Output is correct
30 Correct 39 ms 60780 KB Output is correct
31 Correct 40 ms 61164 KB Output is correct
32 Correct 39 ms 60908 KB Output is correct
33 Correct 51 ms 63980 KB Output is correct
34 Correct 43 ms 62316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 60140 KB Output is correct
2 Correct 38 ms 60140 KB Output is correct
3 Correct 38 ms 60140 KB Output is correct
4 Correct 37 ms 60140 KB Output is correct
5 Correct 37 ms 60140 KB Output is correct
6 Correct 36 ms 60140 KB Output is correct
7 Correct 37 ms 60268 KB Output is correct
8 Correct 37 ms 60140 KB Output is correct
9 Correct 37 ms 60140 KB Output is correct
10 Correct 37 ms 60140 KB Output is correct
11 Correct 38 ms 60268 KB Output is correct
12 Correct 38 ms 60268 KB Output is correct
13 Correct 38 ms 60396 KB Output is correct
14 Correct 39 ms 60396 KB Output is correct
15 Correct 38 ms 60268 KB Output is correct
16 Correct 37 ms 60268 KB Output is correct
17 Correct 41 ms 60396 KB Output is correct
18 Correct 40 ms 60268 KB Output is correct
19 Correct 39 ms 60268 KB Output is correct
20 Correct 43 ms 60396 KB Output is correct
21 Correct 40 ms 60268 KB Output is correct
22 Correct 46 ms 60268 KB Output is correct
23 Correct 39 ms 60396 KB Output is correct
24 Correct 38 ms 60396 KB Output is correct
25 Correct 41 ms 60268 KB Output is correct
26 Correct 38 ms 60396 KB Output is correct
27 Correct 37 ms 60396 KB Output is correct
28 Correct 38 ms 60908 KB Output is correct
29 Correct 41 ms 62060 KB Output is correct
30 Correct 39 ms 60780 KB Output is correct
31 Correct 49 ms 61164 KB Output is correct
32 Correct 43 ms 60908 KB Output is correct
33 Correct 50 ms 63980 KB Output is correct
34 Correct 46 ms 62316 KB Output is correct
35 Correct 62 ms 61676 KB Output is correct
36 Correct 42 ms 60300 KB Output is correct
37 Correct 55 ms 61676 KB Output is correct
38 Correct 59 ms 61292 KB Output is correct
39 Correct 57 ms 60908 KB Output is correct
40 Correct 59 ms 61036 KB Output is correct
41 Correct 64 ms 62060 KB Output is correct
42 Correct 56 ms 60908 KB Output is correct
43 Correct 56 ms 61900 KB Output is correct
44 Correct 57 ms 61804 KB Output is correct
45 Correct 109 ms 74980 KB Output is correct
46 Correct 82 ms 68716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 60140 KB Output is correct
2 Correct 42 ms 60140 KB Output is correct
3 Correct 43 ms 60268 KB Output is correct
4 Correct 38 ms 60140 KB Output is correct
5 Correct 39 ms 60140 KB Output is correct
6 Correct 40 ms 60140 KB Output is correct
7 Correct 39 ms 60140 KB Output is correct
8 Correct 39 ms 60140 KB Output is correct
9 Correct 44 ms 60140 KB Output is correct
10 Correct 45 ms 60140 KB Output is correct
11 Correct 39 ms 60288 KB Output is correct
12 Correct 39 ms 60396 KB Output is correct
13 Correct 38 ms 60268 KB Output is correct
14 Correct 39 ms 60396 KB Output is correct
15 Correct 38 ms 60340 KB Output is correct
16 Correct 38 ms 60268 KB Output is correct
17 Correct 39 ms 60396 KB Output is correct
18 Correct 39 ms 60268 KB Output is correct
19 Correct 38 ms 60268 KB Output is correct
20 Correct 40 ms 60396 KB Output is correct
21 Correct 43 ms 60268 KB Output is correct
22 Correct 38 ms 60268 KB Output is correct
23 Correct 39 ms 60396 KB Output is correct
24 Correct 39 ms 60396 KB Output is correct
25 Correct 39 ms 60268 KB Output is correct
26 Correct 38 ms 60396 KB Output is correct
27 Correct 39 ms 60396 KB Output is correct
28 Correct 41 ms 60908 KB Output is correct
29 Correct 43 ms 62060 KB Output is correct
30 Correct 39 ms 60812 KB Output is correct
31 Correct 40 ms 61164 KB Output is correct
32 Correct 39 ms 60908 KB Output is correct
33 Correct 56 ms 63980 KB Output is correct
34 Correct 44 ms 62316 KB Output is correct
35 Correct 56 ms 61676 KB Output is correct
36 Correct 40 ms 60268 KB Output is correct
37 Correct 52 ms 61676 KB Output is correct
38 Correct 56 ms 61352 KB Output is correct
39 Correct 55 ms 60952 KB Output is correct
40 Correct 54 ms 61036 KB Output is correct
41 Correct 60 ms 62060 KB Output is correct
42 Correct 51 ms 60908 KB Output is correct
43 Correct 53 ms 61804 KB Output is correct
44 Correct 52 ms 61804 KB Output is correct
45 Correct 105 ms 74988 KB Output is correct
46 Correct 81 ms 68716 KB Output is correct
47 Correct 54 ms 61420 KB Output is correct
48 Correct 52 ms 61164 KB Output is correct
49 Correct 51 ms 61164 KB Output is correct
50 Correct 47 ms 60908 KB Output is correct
51 Correct 67 ms 62572 KB Output is correct
52 Correct 71 ms 62700 KB Output is correct
53 Correct 59 ms 61548 KB Output is correct
54 Correct 38 ms 60780 KB Output is correct
55 Correct 39 ms 61036 KB Output is correct
56 Correct 61 ms 63596 KB Output is correct
57 Correct 38 ms 60396 KB Output is correct
58 Correct 57 ms 62956 KB Output is correct
59 Correct 59 ms 63212 KB Output is correct
60 Correct 57 ms 63212 KB Output is correct
61 Correct 59 ms 63468 KB Output is correct
62 Correct 112 ms 74860 KB Output is correct
63 Correct 591 ms 131436 KB Output is correct
64 Correct 497 ms 147480 KB Output is correct
65 Correct 606 ms 186092 KB Output is correct
66 Correct 823 ms 248940 KB Output is correct
67 Correct 478 ms 176492 KB Output is correct