Submission #52663

# Submission time Handle Problem Language Result Execution time Memory
52663 2018-06-26T10:50:12 Z evpipis Jakarta Skyscrapers (APIO15_skyscraper) C++11
57 / 100
1000 ms 65140 KB
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef pair<int, int> ii;

const int len = 30005, inf = 1e9;
int po[len], pos[len], vis[len];
vector<int> vec[len];
unordered_map<int, int> mymap[len];
deque<pair<int, ii> > deq;

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; i++)
        scanf("%d %d", &pos[i], &po[i]);
    for (int i = 0; i < m; i++)
        vec[pos[i]].pb(po[i]);

    int ans = -1;
    deq.pb(mp(0, mp(pos[0], po[0])));
    while (!deq.empty()){
        pair<int, ii> top = deq.front();
        deq.pop_front();

        int d = top.fi, b = top.se.fi, p = top.se.se;
        if (b == pos[1]){
            ans = d;
            break;
        }

        if (mymap[b].count(p)) continue;
        mymap[b][p] = d;
        if (b+p < n)
            deq.pb(mp(d+1, mp(b+p, p)));
        if (b-p >= 0)
            deq.pb(mp(d+1, mp(b-p, p)));

        if (vis[b]) continue;
        vis[b] = 1;
        for (int j = 0; j < vec[b].size(); j++)
            deq.push_front(mp(d, mp(b, vec[b][j])));
    }

    printf("%d\n", ans);
    return 0;
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:45:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = 0; j < vec[b].size(); j++)
                         ~~^~~~~~~~~~~~~~~
skyscraper.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~
skyscraper.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &pos[i], &po[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 4 ms 2716 KB Output is correct
4 Correct 4 ms 2788 KB Output is correct
5 Correct 4 ms 2788 KB Output is correct
6 Correct 4 ms 2788 KB Output is correct
7 Correct 4 ms 2788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2788 KB Output is correct
2 Correct 4 ms 2788 KB Output is correct
3 Correct 4 ms 2848 KB Output is correct
4 Correct 4 ms 2848 KB Output is correct
5 Correct 4 ms 2856 KB Output is correct
6 Correct 4 ms 2864 KB Output is correct
7 Correct 4 ms 2864 KB Output is correct
8 Correct 4 ms 2992 KB Output is correct
9 Correct 4 ms 2992 KB Output is correct
10 Correct 4 ms 2992 KB Output is correct
11 Correct 4 ms 2992 KB Output is correct
12 Correct 4 ms 2992 KB Output is correct
13 Correct 4 ms 3112 KB Output is correct
14 Correct 6 ms 3156 KB Output is correct
15 Correct 5 ms 3156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 3156 KB Output is correct
2 Correct 4 ms 3156 KB Output is correct
3 Correct 4 ms 3156 KB Output is correct
4 Correct 4 ms 3156 KB Output is correct
5 Correct 5 ms 3156 KB Output is correct
6 Correct 4 ms 3156 KB Output is correct
7 Correct 4 ms 3156 KB Output is correct
8 Correct 4 ms 3156 KB Output is correct
9 Correct 4 ms 3156 KB Output is correct
10 Correct 4 ms 3156 KB Output is correct
11 Correct 4 ms 3156 KB Output is correct
12 Correct 4 ms 3156 KB Output is correct
13 Correct 4 ms 3156 KB Output is correct
14 Correct 5 ms 3200 KB Output is correct
15 Correct 5 ms 3200 KB Output is correct
16 Correct 5 ms 3200 KB Output is correct
17 Correct 5 ms 3200 KB Output is correct
18 Correct 4 ms 3200 KB Output is correct
19 Correct 4 ms 3200 KB Output is correct
20 Correct 5 ms 3200 KB Output is correct
21 Correct 4 ms 3200 KB Output is correct
22 Correct 4 ms 3200 KB Output is correct
23 Correct 6 ms 3200 KB Output is correct
24 Correct 6 ms 3324 KB Output is correct
25 Correct 5 ms 3324 KB Output is correct
26 Correct 5 ms 3324 KB Output is correct
27 Correct 5 ms 3324 KB Output is correct
28 Correct 10 ms 3944 KB Output is correct
29 Correct 20 ms 5592 KB Output is correct
30 Correct 8 ms 5592 KB Output is correct
31 Correct 14 ms 5592 KB Output is correct
32 Correct 10 ms 5592 KB Output is correct
33 Correct 38 ms 8060 KB Output is correct
34 Correct 33 ms 8060 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8060 KB Output is correct
2 Correct 4 ms 8060 KB Output is correct
3 Correct 5 ms 8060 KB Output is correct
4 Correct 4 ms 8060 KB Output is correct
5 Correct 4 ms 8060 KB Output is correct
6 Correct 4 ms 8060 KB Output is correct
7 Correct 4 ms 8060 KB Output is correct
8 Correct 4 ms 8060 KB Output is correct
9 Correct 4 ms 8060 KB Output is correct
10 Correct 4 ms 8060 KB Output is correct
11 Correct 4 ms 8060 KB Output is correct
12 Correct 4 ms 8060 KB Output is correct
13 Correct 4 ms 8060 KB Output is correct
14 Correct 5 ms 8060 KB Output is correct
15 Correct 5 ms 8060 KB Output is correct
16 Correct 4 ms 8060 KB Output is correct
17 Correct 5 ms 8060 KB Output is correct
18 Correct 4 ms 8060 KB Output is correct
19 Correct 4 ms 8060 KB Output is correct
20 Correct 5 ms 8060 KB Output is correct
21 Correct 4 ms 8060 KB Output is correct
22 Correct 5 ms 8060 KB Output is correct
23 Correct 6 ms 8060 KB Output is correct
24 Correct 6 ms 8060 KB Output is correct
25 Correct 5 ms 8060 KB Output is correct
26 Correct 5 ms 8060 KB Output is correct
27 Correct 5 ms 8060 KB Output is correct
28 Correct 10 ms 8060 KB Output is correct
29 Correct 21 ms 8060 KB Output is correct
30 Correct 8 ms 8060 KB Output is correct
31 Correct 13 ms 8060 KB Output is correct
32 Correct 10 ms 8060 KB Output is correct
33 Correct 39 ms 8108 KB Output is correct
34 Correct 21 ms 8108 KB Output is correct
35 Correct 18 ms 8108 KB Output is correct
36 Correct 6 ms 8108 KB Output is correct
37 Correct 14 ms 8108 KB Output is correct
38 Correct 15 ms 8108 KB Output is correct
39 Correct 12 ms 8108 KB Output is correct
40 Correct 13 ms 8108 KB Output is correct
41 Correct 13 ms 8108 KB Output is correct
42 Correct 10 ms 8108 KB Output is correct
43 Correct 10 ms 8108 KB Output is correct
44 Correct 18 ms 8108 KB Output is correct
45 Correct 261 ms 23868 KB Output is correct
46 Correct 113 ms 23868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 23868 KB Output is correct
2 Correct 4 ms 23868 KB Output is correct
3 Correct 4 ms 23868 KB Output is correct
4 Correct 4 ms 23868 KB Output is correct
5 Correct 4 ms 23868 KB Output is correct
6 Correct 4 ms 23868 KB Output is correct
7 Correct 4 ms 23868 KB Output is correct
8 Correct 4 ms 23868 KB Output is correct
9 Correct 4 ms 23868 KB Output is correct
10 Correct 4 ms 23868 KB Output is correct
11 Correct 4 ms 23868 KB Output is correct
12 Correct 4 ms 23868 KB Output is correct
13 Correct 5 ms 23868 KB Output is correct
14 Correct 6 ms 23868 KB Output is correct
15 Correct 5 ms 23868 KB Output is correct
16 Correct 4 ms 23868 KB Output is correct
17 Correct 5 ms 23868 KB Output is correct
18 Correct 4 ms 23868 KB Output is correct
19 Correct 4 ms 23868 KB Output is correct
20 Correct 5 ms 23868 KB Output is correct
21 Correct 4 ms 23868 KB Output is correct
22 Correct 4 ms 23868 KB Output is correct
23 Correct 5 ms 23868 KB Output is correct
24 Correct 6 ms 23868 KB Output is correct
25 Correct 5 ms 23868 KB Output is correct
26 Correct 5 ms 23868 KB Output is correct
27 Correct 6 ms 23868 KB Output is correct
28 Correct 10 ms 23868 KB Output is correct
29 Correct 20 ms 23868 KB Output is correct
30 Correct 8 ms 23868 KB Output is correct
31 Correct 14 ms 23868 KB Output is correct
32 Correct 11 ms 23868 KB Output is correct
33 Correct 37 ms 23868 KB Output is correct
34 Correct 21 ms 23868 KB Output is correct
35 Correct 19 ms 23868 KB Output is correct
36 Correct 6 ms 23868 KB Output is correct
37 Correct 13 ms 23868 KB Output is correct
38 Correct 15 ms 23868 KB Output is correct
39 Correct 13 ms 23868 KB Output is correct
40 Correct 13 ms 23868 KB Output is correct
41 Correct 17 ms 23868 KB Output is correct
42 Correct 10 ms 23868 KB Output is correct
43 Correct 11 ms 23868 KB Output is correct
44 Correct 11 ms 23868 KB Output is correct
45 Correct 273 ms 23868 KB Output is correct
46 Correct 110 ms 23868 KB Output is correct
47 Correct 14 ms 23868 KB Output is correct
48 Correct 12 ms 23868 KB Output is correct
49 Correct 12 ms 23868 KB Output is correct
50 Correct 9 ms 23868 KB Output is correct
51 Correct 33 ms 23868 KB Output is correct
52 Correct 37 ms 23868 KB Output is correct
53 Correct 17 ms 23868 KB Output is correct
54 Correct 8 ms 23868 KB Output is correct
55 Correct 9 ms 23868 KB Output is correct
56 Correct 24 ms 23868 KB Output is correct
57 Correct 5 ms 23868 KB Output is correct
58 Correct 30 ms 23868 KB Output is correct
59 Correct 25 ms 23868 KB Output is correct
60 Correct 25 ms 23868 KB Output is correct
61 Correct 26 ms 23868 KB Output is correct
62 Correct 291 ms 24260 KB Output is correct
63 Execution timed out 1080 ms 65140 KB Time limit exceeded
64 Halted 0 ms 0 KB -