답안 #424948

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
424948 2021-06-12T11:56:15 Z TryMax Sky Walking (IOI19_walk) C++17
24 / 100
873 ms 440508 KB
#include "walk.h"
#include <bits/stdc++.h>
#ifdef LOCAL
    #include "grader.cpp"
#endif // LOCAL

#define f first
#define s second
#define ll long long
#define pb push_back

using namespace std;

const ll N = 3e6 + 10, inf = 1e18 + 10;

ll dist[N], pr[N];
int mark[N], cnt = 0;
pair<int, int> lasty[N];
vector<pair<int, int>> a[N];

long long min_distance(vector<int> x, vector<int> h, vector<int> l, vector<int> r, vector<int> y, int s, int g){
	int n = x.size();
	int m = y.size();
	bool wass = false, wasg = false;
	set<pair<int, int>> st;
	vector<pair<int, pair<int, int>>> ev;
	for(int i = 0; i < n; ++i)
        ev.pb({x[i], {1, i}});
    for(int i = 0; i < m; ++i){
        ev.pb({x[l[i]], {0, i}});
        ev.pb({x[r[i]], {2, i}});
        lasty[i] = {-1, -1};
    }
    sort(ev.begin(), ev.end());
    for(auto v : ev){
        if(v.s.f == 1){
//            cout << v.s.s << endl;
//            for(auto v1 : st){
//                cout << v1.f << " " << v1.s << endl;
//            }
            pair<int, int> last = {cnt++, 0};
            if(v.s.s == s && !wass){
                s = last.f;
                wass = 1;
//                cout << v.s.s << " " << s << " " << v.f << " " << cnt << endl;
            }
            if(v.s.s == g && !wasg){
//                cout << v.s.s << " " << s << " " << v.f << " " << cnt << endl;
                g = last.f;
                wasg = 1;
            }
            for(auto v1 : st){
                if(v1.f > h[v.s.s])
                    break;
                a[cnt].pb({last.f, v1.f - last.s});
                a[last.f].pb({cnt, v1.f - last.s});
                if(lasty[v1.s].f != -1){
//                    cout << cnt << " " << lasty[v1.f].f << " " << v.f - lasty[v1.f].s << endl;
                    a[cnt].pb({lasty[v1.s].f, v.f - lasty[v1.s].s});
                    a[lasty[v1.s].f].pb({cnt, v.f - lasty[v1.s].s});
                }
                lasty[v1.s] = {cnt, v.f};
                last = {cnt++, v1.f};
//                cout << "lmao" << endl;
            }
        }else if(v.s.f == 0)
            st.insert({y[v.s.s], v.s.s});
        else
            st.erase(st.find({y[v.s.s], v.s.s}));
	}
//	for(int i = 0; i < cnt; ++i){
//        cout << i << endl;
//        for(auto v : a[i])
//            cout << v.f << " " << v.s << endl;
//	}
    for(int i = 0; i < cnt; ++i)
        dist[i] = inf;
    dist[s] = 0;
    priority_queue<pair<ll, int>> q;
    q.push({0, s});
    while(!q.empty()){
        int u = q.top().s;
        q.pop();
        if(mark[u])
            continue;
        for(auto v : a[u])
            if(dist[u] + v.s < dist[v.f])
                dist[v.f] = dist[u] + v.s, q.push({-1 * dist[v.f], v.f});
        mark[u] = 1;
    }
    if(dist[g] == inf)
        return -1;
    else
        return dist[g];
}
/*
7 7
0 8
3 7
5 9
7 7
10 6
12 6
14 9
0 1 1
0 2 6
0 6 8
2 3 1
2 6 7
3 4 2
4 6 5
1 5

27

5 3
0 6
4 6
5 6
6 6
9 6
3 4 1
1 3 3
0 2 6
0 4

21

3 2
1 4
3 4
5 4
1 3 3
3 5 4
0 2
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 70736 KB Output is correct
2 Correct 53 ms 70632 KB Output is correct
3 Correct 48 ms 70668 KB Output is correct
4 Correct 47 ms 70708 KB Output is correct
5 Correct 47 ms 70736 KB Output is correct
6 Correct 53 ms 70684 KB Output is correct
7 Correct 47 ms 70788 KB Output is correct
8 Correct 54 ms 70816 KB Output is correct
9 Correct 48 ms 70736 KB Output is correct
10 Correct 47 ms 70720 KB Output is correct
11 Correct 47 ms 70852 KB Output is correct
12 Correct 46 ms 70732 KB Output is correct
13 Correct 49 ms 70728 KB Output is correct
14 Correct 52 ms 70748 KB Output is correct
15 Correct 47 ms 70716 KB Output is correct
16 Correct 48 ms 70728 KB Output is correct
17 Correct 54 ms 70728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 70876 KB Output is correct
2 Correct 49 ms 70688 KB Output is correct
3 Correct 438 ms 118072 KB Output is correct
4 Correct 465 ms 123688 KB Output is correct
5 Correct 258 ms 117412 KB Output is correct
6 Correct 248 ms 113032 KB Output is correct
7 Correct 269 ms 117404 KB Output is correct
8 Correct 538 ms 131904 KB Output is correct
9 Correct 292 ms 118028 KB Output is correct
10 Correct 549 ms 145772 KB Output is correct
11 Correct 274 ms 102060 KB Output is correct
12 Correct 223 ms 97452 KB Output is correct
13 Correct 460 ms 137532 KB Output is correct
14 Correct 204 ms 94940 KB Output is correct
15 Correct 203 ms 96740 KB Output is correct
16 Correct 226 ms 96648 KB Output is correct
17 Correct 212 ms 95532 KB Output is correct
18 Correct 283 ms 98676 KB Output is correct
19 Correct 53 ms 71956 KB Output is correct
20 Correct 118 ms 83472 KB Output is correct
21 Correct 190 ms 94872 KB Output is correct
22 Correct 193 ms 96568 KB Output is correct
23 Correct 294 ms 104844 KB Output is correct
24 Correct 206 ms 96428 KB Output is correct
25 Correct 207 ms 95644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 126 ms 80288 KB Output is correct
2 Runtime error 873 ms 440508 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 126 ms 80288 KB Output is correct
2 Runtime error 873 ms 440508 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 70736 KB Output is correct
2 Correct 53 ms 70632 KB Output is correct
3 Correct 48 ms 70668 KB Output is correct
4 Correct 47 ms 70708 KB Output is correct
5 Correct 47 ms 70736 KB Output is correct
6 Correct 53 ms 70684 KB Output is correct
7 Correct 47 ms 70788 KB Output is correct
8 Correct 54 ms 70816 KB Output is correct
9 Correct 48 ms 70736 KB Output is correct
10 Correct 47 ms 70720 KB Output is correct
11 Correct 47 ms 70852 KB Output is correct
12 Correct 46 ms 70732 KB Output is correct
13 Correct 49 ms 70728 KB Output is correct
14 Correct 52 ms 70748 KB Output is correct
15 Correct 47 ms 70716 KB Output is correct
16 Correct 48 ms 70728 KB Output is correct
17 Correct 54 ms 70728 KB Output is correct
18 Correct 49 ms 70876 KB Output is correct
19 Correct 49 ms 70688 KB Output is correct
20 Correct 438 ms 118072 KB Output is correct
21 Correct 465 ms 123688 KB Output is correct
22 Correct 258 ms 117412 KB Output is correct
23 Correct 248 ms 113032 KB Output is correct
24 Correct 269 ms 117404 KB Output is correct
25 Correct 538 ms 131904 KB Output is correct
26 Correct 292 ms 118028 KB Output is correct
27 Correct 549 ms 145772 KB Output is correct
28 Correct 274 ms 102060 KB Output is correct
29 Correct 223 ms 97452 KB Output is correct
30 Correct 460 ms 137532 KB Output is correct
31 Correct 204 ms 94940 KB Output is correct
32 Correct 203 ms 96740 KB Output is correct
33 Correct 226 ms 96648 KB Output is correct
34 Correct 212 ms 95532 KB Output is correct
35 Correct 283 ms 98676 KB Output is correct
36 Correct 53 ms 71956 KB Output is correct
37 Correct 118 ms 83472 KB Output is correct
38 Correct 190 ms 94872 KB Output is correct
39 Correct 193 ms 96568 KB Output is correct
40 Correct 294 ms 104844 KB Output is correct
41 Correct 206 ms 96428 KB Output is correct
42 Correct 207 ms 95644 KB Output is correct
43 Correct 126 ms 80288 KB Output is correct
44 Runtime error 873 ms 440508 KB Execution killed with signal 11
45 Halted 0 ms 0 KB -