답안 #108056

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
108056 2019-04-27T04:13:33 Z oolimry Jakarta Skyscrapers (APIO15_skyscraper) C++14
100 / 100
642 ms 156996 KB
#include <bits/stdc++.h>

using namespace std;
typedef pair<long long, int> ii;
typedef vector<ii> vii;




int main()
{
    //freopen("i.txt","r",stdin);
    long long n, m;
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;

    ii doges[m];
    for(int i = 0;i < m;i++){
        cin >> doges[i].first >> doges[i].second;
    }
    //return 0;
    set<int> power[n];

    for(int i = 0;i < m;i++){
        power[doges[i].first].insert(doges[i].second);
    }
    set<ii> identical;
    vii edges[n];
    for(int i = 0;i < m;i++){
        if(identical.find(doges[i]) != identical.end()) continue;
        identical.insert(doges[i]);
        long long x = doges[i].first;
        long long p = doges[i].second;
        long long a = x + p;
        long long w = 0;
        while(a < n){
            w++;
            //cout << p << "\n";
            edges[x].push_back(ii(w,a));
            if(power[a].find(p) != power[a].end()) break;
            a += p;
        }

        a = x - p;
        w = 0;
        while(a >= 0){
            w++;
            edges[x].push_back(ii(w,a));
            if(power[a].find(p) != power[a].end()) break;
            a -= p;
        }
    }



    long long dis[n];
    fill(dis,dis+n,102345678901233ll);
    dis[doges[0].first] = 0;

    priority_queue<ii, vector<ii>, greater<ii> > pq;

    pq.push(ii(0,doges[0].first));
    while(!pq.empty()){
        ii u = pq.top();
        pq.pop();
        for(int j = 0;j < edges[u.second].size();j++){
            ii v = edges[u.second][j];
            if(dis[v.second] > v.first + u.first){
                dis[v.second] = v.first + u.first;
                pq.push(ii(dis[v.second],v.second));
            }
        }
    }
    if(dis[doges[1].first] > 10234567891ll) cout << -1;
    else cout << dis[doges[1].first];


    return 0;
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:67:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j = 0;j < edges[u.second].size();j++){
                       ~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 256 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 4 ms 640 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 4 ms 768 KB Output is correct
15 Correct 4 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 5 ms 768 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 4 ms 640 KB Output is correct
15 Correct 4 ms 768 KB Output is correct
16 Correct 4 ms 512 KB Output is correct
17 Correct 5 ms 1024 KB Output is correct
18 Correct 4 ms 768 KB Output is correct
19 Correct 3 ms 640 KB Output is correct
20 Correct 4 ms 896 KB Output is correct
21 Correct 4 ms 512 KB Output is correct
22 Correct 2 ms 640 KB Output is correct
23 Correct 3 ms 768 KB Output is correct
24 Correct 6 ms 1024 KB Output is correct
25 Correct 6 ms 1024 KB Output is correct
26 Correct 5 ms 768 KB Output is correct
27 Correct 3 ms 768 KB Output is correct
28 Correct 4 ms 1152 KB Output is correct
29 Correct 8 ms 2304 KB Output is correct
30 Correct 4 ms 1152 KB Output is correct
31 Correct 4 ms 1536 KB Output is correct
32 Correct 4 ms 1280 KB Output is correct
33 Correct 12 ms 3580 KB Output is correct
34 Correct 10 ms 3516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 640 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 5 ms 768 KB Output is correct
15 Correct 5 ms 768 KB Output is correct
16 Correct 3 ms 512 KB Output is correct
17 Correct 6 ms 1024 KB Output is correct
18 Correct 4 ms 768 KB Output is correct
19 Correct 2 ms 640 KB Output is correct
20 Correct 5 ms 896 KB Output is correct
21 Correct 3 ms 512 KB Output is correct
22 Correct 4 ms 640 KB Output is correct
23 Correct 3 ms 768 KB Output is correct
24 Correct 5 ms 1024 KB Output is correct
25 Correct 4 ms 1024 KB Output is correct
26 Correct 3 ms 768 KB Output is correct
27 Correct 3 ms 768 KB Output is correct
28 Correct 4 ms 1280 KB Output is correct
29 Correct 8 ms 2304 KB Output is correct
30 Correct 4 ms 1152 KB Output is correct
31 Correct 5 ms 1536 KB Output is correct
32 Correct 4 ms 1280 KB Output is correct
33 Correct 12 ms 3580 KB Output is correct
34 Correct 11 ms 3580 KB Output is correct
35 Correct 50 ms 5756 KB Output is correct
36 Correct 7 ms 1376 KB Output is correct
37 Correct 39 ms 7032 KB Output is correct
38 Correct 70 ms 7796 KB Output is correct
39 Correct 55 ms 7836 KB Output is correct
40 Correct 57 ms 7828 KB Output is correct
41 Correct 61 ms 7800 KB Output is correct
42 Correct 11 ms 1280 KB Output is correct
43 Correct 9 ms 1152 KB Output is correct
44 Correct 8 ms 1280 KB Output is correct
45 Correct 62 ms 13296 KB Output is correct
46 Correct 73 ms 13296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 284 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 512 KB Output is correct
11 Correct 4 ms 640 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 4 ms 768 KB Output is correct
15 Correct 4 ms 768 KB Output is correct
16 Correct 3 ms 512 KB Output is correct
17 Correct 5 ms 1024 KB Output is correct
18 Correct 3 ms 768 KB Output is correct
19 Correct 2 ms 640 KB Output is correct
20 Correct 5 ms 896 KB Output is correct
21 Correct 3 ms 512 KB Output is correct
22 Correct 3 ms 640 KB Output is correct
23 Correct 3 ms 768 KB Output is correct
24 Correct 5 ms 1024 KB Output is correct
25 Correct 4 ms 1024 KB Output is correct
26 Correct 3 ms 768 KB Output is correct
27 Correct 3 ms 768 KB Output is correct
28 Correct 5 ms 1280 KB Output is correct
29 Correct 7 ms 2304 KB Output is correct
30 Correct 4 ms 1152 KB Output is correct
31 Correct 6 ms 1536 KB Output is correct
32 Correct 4 ms 1276 KB Output is correct
33 Correct 14 ms 3580 KB Output is correct
34 Correct 6 ms 3516 KB Output is correct
35 Correct 44 ms 5756 KB Output is correct
36 Correct 7 ms 1408 KB Output is correct
37 Correct 59 ms 7004 KB Output is correct
38 Correct 80 ms 7800 KB Output is correct
39 Correct 66 ms 7928 KB Output is correct
40 Correct 50 ms 7772 KB Output is correct
41 Correct 69 ms 7800 KB Output is correct
42 Correct 9 ms 1152 KB Output is correct
43 Correct 7 ms 1152 KB Output is correct
44 Correct 8 ms 1280 KB Output is correct
45 Correct 74 ms 13296 KB Output is correct
46 Correct 73 ms 13312 KB Output is correct
47 Correct 141 ms 22380 KB Output is correct
48 Correct 70 ms 9628 KB Output is correct
49 Correct 44 ms 7928 KB Output is correct
50 Correct 43 ms 7284 KB Output is correct
51 Correct 126 ms 13936 KB Output is correct
52 Correct 119 ms 14780 KB Output is correct
53 Correct 56 ms 9328 KB Output is correct
54 Correct 7 ms 3580 KB Output is correct
55 Correct 11 ms 4472 KB Output is correct
56 Correct 56 ms 8060 KB Output is correct
57 Correct 95 ms 19924 KB Output is correct
58 Correct 15 ms 5624 KB Output is correct
59 Correct 21 ms 5896 KB Output is correct
60 Correct 24 ms 7420 KB Output is correct
61 Correct 28 ms 6128 KB Output is correct
62 Correct 101 ms 16156 KB Output is correct
63 Correct 259 ms 55568 KB Output is correct
64 Correct 265 ms 72840 KB Output is correct
65 Correct 353 ms 99304 KB Output is correct
66 Correct 611 ms 156996 KB Output is correct
67 Correct 642 ms 156384 KB Output is correct