Submission #595455

# Submission time Handle Problem Language Result Execution time Memory
595455 2022-07-13T18:39:14 Z Lucpp Sky Walking (IOI19_walk) C++17
33 / 100
174 ms 20164 KB
#include "walk.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 2e18;

ll min_distance(vector<int> X, vector<int> H, vector<int> L, vector<int> R, vector<int> Y, int start, int goal) {
	int n = (int)X.size(), m = (int)L.size();
	vector<vector<pair<int, int>>> todo(n+1);
    for(int i = 0; i < m; i++){
        todo[L[i]].emplace_back(Y[i], 1);
        todo[R[i]+1].emplace_back(Y[i], -1);
    }
    todo[1].emplace_back(0, -1);
    map<int, ll> mp;
    mp[0] = 0;
    set<int> just_added;
	for(int i = 0; i < n; i++){
        for(auto [y, op] : todo[i]){
            if(op == -1 && !just_added.count(y)) mp.erase(y);
        }
        just_added.clear();
        for(auto [y, op] : todo[i]){
            if(op == 1){
                auto it = mp.lower_bound(y);
                ll v = INF;
                if(it != mp.end()) v = min(v, it->second+it->first-y);
                if(it != mp.begin()){
                    it--;
                    v = min(v, it->second+y-it->first);
                }
                if(v == INF) continue;
                mp[y] = v;
                just_added.insert(y);
            }
        }
	}
    if(mp.empty()) return -1;
    return mp.begin()->first+mp.begin()->second+X[n-1]-X[0];
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 28 ms 4012 KB Output is correct
2 Correct 92 ms 6860 KB Output is correct
3 Correct 102 ms 7936 KB Output is correct
4 Correct 133 ms 14460 KB Output is correct
5 Correct 154 ms 20164 KB Output is correct
6 Correct 126 ms 16808 KB Output is correct
7 Correct 58 ms 10648 KB Output is correct
8 Correct 88 ms 13632 KB Output is correct
9 Correct 129 ms 17172 KB Output is correct
10 Correct 97 ms 16556 KB Output is correct
11 Correct 10 ms 3000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 4012 KB Output is correct
2 Correct 92 ms 6860 KB Output is correct
3 Correct 102 ms 7936 KB Output is correct
4 Correct 133 ms 14460 KB Output is correct
5 Correct 154 ms 20164 KB Output is correct
6 Correct 126 ms 16808 KB Output is correct
7 Correct 58 ms 10648 KB Output is correct
8 Correct 88 ms 13632 KB Output is correct
9 Correct 129 ms 17172 KB Output is correct
10 Correct 97 ms 16556 KB Output is correct
11 Correct 10 ms 3000 KB Output is correct
12 Correct 99 ms 7948 KB Output is correct
13 Correct 80 ms 14008 KB Output is correct
14 Correct 141 ms 20128 KB Output is correct
15 Correct 108 ms 14924 KB Output is correct
16 Correct 114 ms 15032 KB Output is correct
17 Correct 117 ms 15008 KB Output is correct
18 Correct 103 ms 14784 KB Output is correct
19 Correct 102 ms 15016 KB Output is correct
20 Correct 69 ms 10776 KB Output is correct
21 Correct 25 ms 6184 KB Output is correct
22 Correct 99 ms 12860 KB Output is correct
23 Correct 94 ms 13188 KB Output is correct
24 Correct 87 ms 14368 KB Output is correct
25 Correct 77 ms 12788 KB Output is correct
26 Correct 90 ms 16200 KB Output is correct
27 Correct 174 ms 19120 KB Output is correct
28 Correct 75 ms 13992 KB Output is correct
29 Correct 163 ms 16696 KB Output is correct
30 Correct 79 ms 10728 KB Output is correct
31 Correct 133 ms 17208 KB Output is correct
32 Correct 104 ms 13800 KB Output is correct
33 Correct 98 ms 14728 KB Output is correct
34 Correct 100 ms 14764 KB Output is correct
35 Correct 99 ms 12916 KB Output is correct
36 Correct 87 ms 12532 KB Output is correct
37 Correct 80 ms 11240 KB Output is correct
38 Correct 86 ms 12848 KB Output is correct
39 Correct 100 ms 16024 KB Output is correct
40 Correct 70 ms 12748 KB Output is correct
41 Correct 90 ms 11848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -