답안 #566594

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
566594 2022-05-22T12:46:04 Z ac2hu Jakarta Skyscrapers (APIO15_skyscraper) C++14
100 / 100
740 ms 8036 KB
#include <bits/stdc++.h>
#ifdef DEBUG
#include "../templates/debug.h"
#else 
#define deb(x...)
#endif
using namespace std;
#define int long long 
signed main() {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    int n, m;cin >> n >> m;
    n++;
    vector<pair<int,int>> doge(m);
    for(auto &[x,y] : doge)cin >> x >> y;
    vector<set<int>> val(n);
    for(auto [x, y] : doge){
        val[x].insert(y);
    }
    vector<int> dist(n, 1e18);
    dist[doge[0].first] = 0;
    priority_queue<pair<int,int>> pq;
    pq.push({-dist[doge[0].first], doge[0].first});
    while(!pq.empty()){
        auto [dd, x] = pq.top();
        pq.pop();
        dd = -dd;
        if(dist[x] < dd)continue;
        for(int e : val[x]){
            int c = 0;
            for(int j = x;j<n;j+=e){
                if(dist[j] > dist[x] + c){
                    dist[j] = dist[x] + c;
                    pq.push({-dist[j], j});
                }
                c++;
            } 
            c = 0;
            for(int j = x;j>=0;j-=e){
                if(dist[j] > dist[x] + c){
                    dist[j] = dist[x] + c;
                    pq.push({-dist[j], j});
                }
                c++;
            } 
        }
    }
    int r = doge[1].first;
    if(dist[r] > 1e17)
        cout << -1 << "\n";
    else
        cout << dist[r] << "\n";
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:15:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   15 |     for(auto &[x,y] : doge)cin >> x >> y;
      |               ^
skyscraper.cpp:17:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   17 |     for(auto [x, y] : doge){
      |              ^
skyscraper.cpp:25:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   25 |         auto [dd, x] = pq.top();
      |              ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 224 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 5 ms 596 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 2 ms 596 KB Output is correct
25 Correct 2 ms 596 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 2 ms 852 KB Output is correct
30 Correct 2 ms 596 KB Output is correct
31 Correct 2 ms 596 KB Output is correct
32 Correct 2 ms 596 KB Output is correct
33 Correct 3 ms 852 KB Output is correct
34 Correct 4 ms 852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 2 ms 476 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 5 ms 624 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 2 ms 468 KB Output is correct
24 Correct 1 ms 488 KB Output is correct
25 Correct 1 ms 596 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 2 ms 852 KB Output is correct
30 Correct 1 ms 596 KB Output is correct
31 Correct 2 ms 596 KB Output is correct
32 Correct 1 ms 596 KB Output is correct
33 Correct 3 ms 852 KB Output is correct
34 Correct 3 ms 852 KB Output is correct
35 Correct 9 ms 2004 KB Output is correct
36 Correct 2 ms 724 KB Output is correct
37 Correct 9 ms 1748 KB Output is correct
38 Correct 12 ms 2516 KB Output is correct
39 Correct 12 ms 2516 KB Output is correct
40 Correct 11 ms 2492 KB Output is correct
41 Correct 11 ms 2492 KB Output is correct
42 Correct 5 ms 852 KB Output is correct
43 Correct 6 ms 852 KB Output is correct
44 Correct 10 ms 980 KB Output is correct
45 Correct 16 ms 2644 KB Output is correct
46 Correct 13 ms 2604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 4 ms 596 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 2 ms 468 KB Output is correct
24 Correct 1 ms 596 KB Output is correct
25 Correct 1 ms 596 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 2 ms 852 KB Output is correct
30 Correct 1 ms 596 KB Output is correct
31 Correct 1 ms 596 KB Output is correct
32 Correct 1 ms 596 KB Output is correct
33 Correct 2 ms 852 KB Output is correct
34 Correct 2 ms 852 KB Output is correct
35 Correct 8 ms 2004 KB Output is correct
36 Correct 2 ms 724 KB Output is correct
37 Correct 7 ms 1748 KB Output is correct
38 Correct 11 ms 2516 KB Output is correct
39 Correct 12 ms 2456 KB Output is correct
40 Correct 11 ms 2516 KB Output is correct
41 Correct 12 ms 2516 KB Output is correct
42 Correct 4 ms 936 KB Output is correct
43 Correct 4 ms 852 KB Output is correct
44 Correct 8 ms 980 KB Output is correct
45 Correct 13 ms 2644 KB Output is correct
46 Correct 14 ms 2688 KB Output is correct
47 Correct 16 ms 3660 KB Output is correct
48 Correct 7 ms 3008 KB Output is correct
49 Correct 6 ms 3028 KB Output is correct
50 Correct 4 ms 2772 KB Output is correct
51 Correct 25 ms 6020 KB Output is correct
52 Correct 24 ms 4996 KB Output is correct
53 Correct 14 ms 4940 KB Output is correct
54 Correct 3 ms 2264 KB Output is correct
55 Correct 3 ms 2264 KB Output is correct
56 Correct 740 ms 4432 KB Output is correct
57 Correct 53 ms 6348 KB Output is correct
58 Correct 7 ms 2776 KB Output is correct
59 Correct 7 ms 2772 KB Output is correct
60 Correct 10 ms 2856 KB Output is correct
61 Correct 8 ms 2904 KB Output is correct
62 Correct 10 ms 3864 KB Output is correct
63 Correct 31 ms 6044 KB Output is correct
64 Correct 28 ms 5960 KB Output is correct
65 Correct 32 ms 6012 KB Output is correct
66 Correct 56 ms 8036 KB Output is correct
67 Correct 62 ms 7996 KB Output is correct