Submission #52634

# Submission time Handle Problem Language Result Execution time Memory
52634 2018-06-26T10:10:35 Z evpipis Jakarta Skyscrapers (APIO15_skyscraper) C++11
57 / 100
1000 ms 71076 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];
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 2424 KB Output is correct
2 Correct 3 ms 2536 KB Output is correct
3 Correct 3 ms 2604 KB Output is correct
4 Correct 3 ms 2604 KB Output is correct
5 Correct 3 ms 2604 KB Output is correct
6 Correct 3 ms 2608 KB Output is correct
7 Correct 3 ms 2668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2668 KB Output is correct
2 Correct 3 ms 2668 KB Output is correct
3 Correct 3 ms 2668 KB Output is correct
4 Correct 3 ms 2668 KB Output is correct
5 Correct 4 ms 2668 KB Output is correct
6 Correct 3 ms 2668 KB Output is correct
7 Correct 4 ms 2668 KB Output is correct
8 Correct 3 ms 2668 KB Output is correct
9 Correct 3 ms 2668 KB Output is correct
10 Correct 4 ms 2668 KB Output is correct
11 Correct 5 ms 2668 KB Output is correct
12 Correct 4 ms 2668 KB Output is correct
13 Correct 4 ms 2668 KB Output is correct
14 Correct 5 ms 3044 KB Output is correct
15 Correct 4 ms 3044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 3044 KB Output is correct
2 Correct 3 ms 3044 KB Output is correct
3 Correct 3 ms 3044 KB Output is correct
4 Correct 3 ms 3044 KB Output is correct
5 Correct 3 ms 3044 KB Output is correct
6 Correct 3 ms 3044 KB Output is correct
7 Correct 3 ms 3044 KB Output is correct
8 Correct 3 ms 3044 KB Output is correct
9 Correct 3 ms 3044 KB Output is correct
10 Correct 4 ms 3044 KB Output is correct
11 Correct 4 ms 3044 KB Output is correct
12 Correct 4 ms 3044 KB Output is correct
13 Correct 4 ms 3044 KB Output is correct
14 Correct 5 ms 3044 KB Output is correct
15 Correct 5 ms 3044 KB Output is correct
16 Correct 4 ms 3044 KB Output is correct
17 Correct 6 ms 3044 KB Output is correct
18 Correct 4 ms 3044 KB Output is correct
19 Correct 4 ms 3044 KB Output is correct
20 Correct 4 ms 3044 KB Output is correct
21 Correct 4 ms 3044 KB Output is correct
22 Correct 4 ms 3044 KB Output is correct
23 Correct 4 ms 3044 KB Output is correct
24 Correct 6 ms 3068 KB Output is correct
25 Correct 7 ms 3068 KB Output is correct
26 Correct 6 ms 3068 KB Output is correct
27 Correct 6 ms 3068 KB Output is correct
28 Correct 10 ms 3708 KB Output is correct
29 Correct 30 ms 5720 KB Output is correct
30 Correct 7 ms 5720 KB Output is correct
31 Correct 13 ms 5720 KB Output is correct
32 Correct 11 ms 5720 KB Output is correct
33 Correct 81 ms 8700 KB Output is correct
34 Correct 28 ms 8700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 8700 KB Output is correct
2 Correct 3 ms 8700 KB Output is correct
3 Correct 4 ms 8700 KB Output is correct
4 Correct 4 ms 8700 KB Output is correct
5 Correct 3 ms 8700 KB Output is correct
6 Correct 3 ms 8700 KB Output is correct
7 Correct 4 ms 8700 KB Output is correct
8 Correct 3 ms 8700 KB Output is correct
9 Correct 4 ms 8700 KB Output is correct
10 Correct 4 ms 8700 KB Output is correct
11 Correct 4 ms 8700 KB Output is correct
12 Correct 4 ms 8700 KB Output is correct
13 Correct 6 ms 8700 KB Output is correct
14 Correct 8 ms 8700 KB Output is correct
15 Correct 5 ms 8700 KB Output is correct
16 Correct 4 ms 8700 KB Output is correct
17 Correct 5 ms 8700 KB Output is correct
18 Correct 4 ms 8700 KB Output is correct
19 Correct 4 ms 8700 KB Output is correct
20 Correct 5 ms 8700 KB Output is correct
21 Correct 4 ms 8700 KB Output is correct
22 Correct 4 ms 8700 KB Output is correct
23 Correct 7 ms 8700 KB Output is correct
24 Correct 7 ms 8700 KB Output is correct
25 Correct 5 ms 8700 KB Output is correct
26 Correct 6 ms 8700 KB Output is correct
27 Correct 6 ms 8700 KB Output is correct
28 Correct 12 ms 8700 KB Output is correct
29 Correct 24 ms 8700 KB Output is correct
30 Correct 7 ms 8700 KB Output is correct
31 Correct 17 ms 8700 KB Output is correct
32 Correct 8 ms 8700 KB Output is correct
33 Correct 52 ms 8700 KB Output is correct
34 Correct 26 ms 8700 KB Output is correct
35 Correct 18 ms 8700 KB Output is correct
36 Correct 5 ms 8700 KB Output is correct
37 Correct 12 ms 8700 KB Output is correct
38 Correct 16 ms 8700 KB Output is correct
39 Correct 12 ms 8700 KB Output is correct
40 Correct 12 ms 8700 KB Output is correct
41 Correct 13 ms 8700 KB Output is correct
42 Correct 11 ms 8700 KB Output is correct
43 Correct 11 ms 8700 KB Output is correct
44 Correct 10 ms 8700 KB Output is correct
45 Correct 374 ms 26460 KB Output is correct
46 Correct 159 ms 26460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 26460 KB Output is correct
2 Correct 4 ms 26460 KB Output is correct
3 Correct 5 ms 26460 KB Output is correct
4 Correct 4 ms 26460 KB Output is correct
5 Correct 5 ms 26460 KB Output is correct
6 Correct 4 ms 26460 KB Output is correct
7 Correct 4 ms 26460 KB Output is correct
8 Correct 4 ms 26460 KB Output is correct
9 Correct 4 ms 26460 KB Output is correct
10 Correct 4 ms 26460 KB Output is correct
11 Correct 4 ms 26460 KB Output is correct
12 Correct 4 ms 26460 KB Output is correct
13 Correct 4 ms 26460 KB Output is correct
14 Correct 6 ms 26460 KB Output is correct
15 Correct 6 ms 26460 KB Output is correct
16 Correct 4 ms 26460 KB Output is correct
17 Correct 6 ms 26460 KB Output is correct
18 Correct 5 ms 26460 KB Output is correct
19 Correct 5 ms 26460 KB Output is correct
20 Correct 5 ms 26460 KB Output is correct
21 Correct 5 ms 26460 KB Output is correct
22 Correct 5 ms 26460 KB Output is correct
23 Correct 5 ms 26460 KB Output is correct
24 Correct 6 ms 26460 KB Output is correct
25 Correct 5 ms 26460 KB Output is correct
26 Correct 5 ms 26460 KB Output is correct
27 Correct 5 ms 26460 KB Output is correct
28 Correct 9 ms 26460 KB Output is correct
29 Correct 24 ms 26460 KB Output is correct
30 Correct 8 ms 26460 KB Output is correct
31 Correct 13 ms 26460 KB Output is correct
32 Correct 9 ms 26460 KB Output is correct
33 Correct 57 ms 26460 KB Output is correct
34 Correct 28 ms 26460 KB Output is correct
35 Correct 21 ms 26460 KB Output is correct
36 Correct 6 ms 26460 KB Output is correct
37 Correct 12 ms 26460 KB Output is correct
38 Correct 14 ms 26460 KB Output is correct
39 Correct 12 ms 26460 KB Output is correct
40 Correct 12 ms 26460 KB Output is correct
41 Correct 14 ms 26460 KB Output is correct
42 Correct 10 ms 26460 KB Output is correct
43 Correct 16 ms 26460 KB Output is correct
44 Correct 10 ms 26460 KB Output is correct
45 Correct 400 ms 26472 KB Output is correct
46 Correct 209 ms 26472 KB Output is correct
47 Correct 15 ms 26472 KB Output is correct
48 Correct 16 ms 26472 KB Output is correct
49 Correct 17 ms 26472 KB Output is correct
50 Correct 11 ms 26472 KB Output is correct
51 Correct 34 ms 26472 KB Output is correct
52 Correct 43 ms 26472 KB Output is correct
53 Correct 28 ms 26472 KB Output is correct
54 Correct 6 ms 26472 KB Output is correct
55 Correct 8 ms 26472 KB Output is correct
56 Correct 18 ms 26472 KB Output is correct
57 Correct 5 ms 26472 KB Output is correct
58 Correct 18 ms 26472 KB Output is correct
59 Correct 18 ms 26472 KB Output is correct
60 Correct 22 ms 26472 KB Output is correct
61 Correct 18 ms 26472 KB Output is correct
62 Correct 305 ms 26472 KB Output is correct
63 Execution timed out 1083 ms 71076 KB Time limit exceeded
64 Halted 0 ms 0 KB -