답안 #1063745

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1063745 2024-08-18T00:54:07 Z aaaaaarroz Sky Walking (IOI19_walk) C++17
24 / 100
3903 ms 1048576 KB
    #include <bits/stdc++.h>
    #include "walk.h"
    using namespace std;
     
    typedef long long ll;
     
    ll n, m;
    vector<vector<pair<ll, ll>>> ints; // y, nodeId
    vector<pair<ll, pair<ll, ll>>> bridges;
    ll cnt;
     
    vector<vector<pair<ll, ll>>> adj;
     
    ll min_distance(vector<int> x, vector<int> h, vector<int> l, vector<int> r, vector<int> y, int s, int g) {
        n = x.size(); m = y.size();
        cnt = 0;
        ints = vector<vector<pair<ll, ll>>>(n);
        ints[s].push_back({0, cnt++});
        ints[g].push_back({0, cnt++});
        bridges = vector<pair<ll, pair<ll, ll>>>(m);
        for (int i = 0; i < m; i++) {
            bridges[i] = {y[i], {l[i], r[i]}};
        }
        sort(bridges.begin(), bridges.end());
        vector<vector<pair<ll, ll>>> it(m); // x, nodeId
        vector<ll> lnk(n);
        for (int i = 0; i < n; i++) lnk[i] = i+1;
        for (int j = 0; j < m; j++) {
            pair<ll, ll> p = bridges[j].second;
            ll lastCorr = -1;
            for (int i = p.first; i <= p.second; i = lnk[i]) {
                if (bridges[j].first > h[i]) continue;
                if (lastCorr != -1) {
                    lnk[lastCorr] = i;
                }
                it[j].push_back({x[i], cnt});
                ints[i].push_back({bridges[j].first, cnt++});
                lastCorr = i;
            }
        }
     
        adj = vector<vector<pair<ll, ll>>>(cnt); // dist, nodeId
        for (auto &e : ints) { // SIGNAL 11
            if (e.size() < 2) continue;
            for (int i = 0; i < e.size()-1; i++) {
                ll dist = e[i+1].first - e[i].first;
                adj[e[i].second].push_back({dist, e[i+1].second});
                adj[e[i+1].second].push_back({dist, e[i].second});
            }
        }
        for (auto &e : it) {
            for (int i = 0; i < e.size()-1; i++) {
                adj[e[i].second].push_back({e[i+1].first - e[i].first, e[i+1].second});
                adj[e[i+1].second].push_back({e[i+1].first - e[i].first, e[i].second});
            }
        }
     
        priority_queue<pair<ll, ll>> q;
        q.push({0, 0});
        vector<ll> dist(cnt, 1ll << 62ll);
        dist[0] = 0;
        vector<bool> vst(cnt);
        while (!q.empty()) {
            ll cur = q.top().second; q.pop();
            if (vst[cur]) continue;
            vst[cur] = true;
            for (auto &e : adj[cur]) {
                dist[e.second] = min(dist[e.second], dist[cur] + e.first);
                q.push({-dist[e.second], e.second});
            }
        }
     
        return dist[1] == 1ll << 62ll ? -1 : dist[1];
    }

Compilation message

walk.cpp: In function 'll min_distance(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, int, int)':
walk.cpp:45:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |             for (int i = 0; i < e.size()-1; i++) {
      |                             ~~^~~~~~~~~~~~
walk.cpp:52:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |             for (int i = 0; i < e.size()-1; i++) {
      |                             ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 428 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 416 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 1 ms 436 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 594 ms 124944 KB Output is correct
4 Correct 535 ms 128756 KB Output is correct
5 Correct 255 ms 110672 KB Output is correct
6 Correct 225 ms 98008 KB Output is correct
7 Correct 254 ms 110904 KB Output is correct
8 Correct 745 ms 157460 KB Output is correct
9 Correct 303 ms 112212 KB Output is correct
10 Correct 780 ms 182456 KB Output is correct
11 Correct 260 ms 68648 KB Output is correct
12 Correct 116 ms 42168 KB Output is correct
13 Correct 652 ms 161524 KB Output is correct
14 Correct 80 ms 40532 KB Output is correct
15 Correct 84 ms 42836 KB Output is correct
16 Correct 95 ms 43784 KB Output is correct
17 Correct 92 ms 42576 KB Output is correct
18 Correct 112 ms 47412 KB Output is correct
19 Correct 5 ms 2396 KB Output is correct
20 Correct 44 ms 19908 KB Output is correct
21 Correct 103 ms 42324 KB Output is correct
22 Correct 81 ms 41040 KB Output is correct
23 Correct 122 ms 50272 KB Output is correct
24 Correct 87 ms 42600 KB Output is correct
25 Correct 91 ms 43092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 22608 KB Output is correct
2 Correct 3903 ms 799932 KB Output is correct
3 Runtime error 927 ms 1048576 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 22608 KB Output is correct
2 Correct 3903 ms 799932 KB Output is correct
3 Runtime error 927 ms 1048576 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 428 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 416 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 1 ms 436 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 594 ms 124944 KB Output is correct
21 Correct 535 ms 128756 KB Output is correct
22 Correct 255 ms 110672 KB Output is correct
23 Correct 225 ms 98008 KB Output is correct
24 Correct 254 ms 110904 KB Output is correct
25 Correct 745 ms 157460 KB Output is correct
26 Correct 303 ms 112212 KB Output is correct
27 Correct 780 ms 182456 KB Output is correct
28 Correct 260 ms 68648 KB Output is correct
29 Correct 116 ms 42168 KB Output is correct
30 Correct 652 ms 161524 KB Output is correct
31 Correct 80 ms 40532 KB Output is correct
32 Correct 84 ms 42836 KB Output is correct
33 Correct 95 ms 43784 KB Output is correct
34 Correct 92 ms 42576 KB Output is correct
35 Correct 112 ms 47412 KB Output is correct
36 Correct 5 ms 2396 KB Output is correct
37 Correct 44 ms 19908 KB Output is correct
38 Correct 103 ms 42324 KB Output is correct
39 Correct 81 ms 41040 KB Output is correct
40 Correct 122 ms 50272 KB Output is correct
41 Correct 87 ms 42600 KB Output is correct
42 Correct 91 ms 43092 KB Output is correct
43 Correct 43 ms 22608 KB Output is correct
44 Correct 3903 ms 799932 KB Output is correct
45 Runtime error 927 ms 1048576 KB Execution killed with signal 9
46 Halted 0 ms 0 KB -