답안 #723928

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
723928 2023-04-14T13:13:46 Z GrandTiger1729 Sky Walking (IOI19_walk) C++17
33 / 100
184 ms 21544 KB
#include "walk.h"
#ifndef EVAL
#include "grader.cpp"
#endif

#include <bits/stdc++.h>
using namespace std;

const long long INF = 1e18;
long long min_distance(vector<int> a, vector<int> h, vector<int> l, vector<int> r, vector<int> b, int s, int g){
	int n = a.size(), m = l.size();
	vector<vector<int>> ll(n), rr(n);
	for (int i = 0; i < m; i++){
		ll[l[i]].push_back(b[i]);
		rr[r[i]].push_back(b[i]);
	}
	map<int, long long> mp;
	for (int &j: ll[0])
		mp[j] = j;
	// cerr << "OK" << endl;
	for (int i = 1; i < n - 1; i++){
		set<int> vis;
		for (int &j: ll[i]){
			auto it = mp.lower_bound(j);
			if (it != mp.end()){
				if (it->first != j)
					mp[j] = it->second + it->first - j;
				else
					vis.insert(j);
			}
			if (mp.size() && it != mp.begin() && it->first != j){
				it--;
				if (mp.find(j) == mp.end())
					mp[j] = it->second + j - it->first;
				else
					mp[j] = min(mp[j], it->second + j - it->first);
			}
		}
		// cerr << "OK" << endl;
		for (int &j: rr[i]){
			if (vis.count(j))
				continue;
			auto it = mp.lower_bound(j);
			if (it == mp.end())
				continue;
			{
				auto it2 = it;
				it2++;
				if (it2 != mp.end())
					it2->second = min(it2->second, it->second + it2->first - j);
			}
			// cerr << "OKK" << endl;
			if (it != mp.begin()){
				auto it2 = it;
				it2--;
				it2->second = min(it2->second, it->second + j - it2->first);
			}
			mp.erase(it);
		}
		// cerr << i << ' ' << mp.size() << endl;
		// for (auto &it: mp)
		// 	cerr << it.first << ' ' << it.second << endl;
		// cerr << endl;
	}
	long long ans = INF;
	for (auto &it: mp){
		ans = min(ans, it.first + it.second);
	}
	ans += a[g] - a[s];
	return ans >= INF? -1: ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 3028 KB Output is correct
2 Correct 92 ms 4128 KB Output is correct
3 Correct 96 ms 5068 KB Output is correct
4 Correct 135 ms 13160 KB Output is correct
5 Correct 163 ms 17464 KB Output is correct
6 Correct 184 ms 19560 KB Output is correct
7 Correct 67 ms 13604 KB Output is correct
8 Correct 87 ms 19104 KB Output is correct
9 Correct 156 ms 20928 KB Output is correct
10 Correct 97 ms 19012 KB Output is correct
11 Correct 11 ms 4180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 3028 KB Output is correct
2 Correct 92 ms 4128 KB Output is correct
3 Correct 96 ms 5068 KB Output is correct
4 Correct 135 ms 13160 KB Output is correct
5 Correct 163 ms 17464 KB Output is correct
6 Correct 184 ms 19560 KB Output is correct
7 Correct 67 ms 13604 KB Output is correct
8 Correct 87 ms 19104 KB Output is correct
9 Correct 156 ms 20928 KB Output is correct
10 Correct 97 ms 19012 KB Output is correct
11 Correct 11 ms 4180 KB Output is correct
12 Correct 95 ms 7288 KB Output is correct
13 Correct 80 ms 16836 KB Output is correct
14 Correct 164 ms 21544 KB Output is correct
15 Correct 106 ms 17068 KB Output is correct
16 Correct 111 ms 17228 KB Output is correct
17 Correct 109 ms 17200 KB Output is correct
18 Correct 101 ms 17044 KB Output is correct
19 Correct 103 ms 17220 KB Output is correct
20 Correct 72 ms 13616 KB Output is correct
21 Correct 24 ms 8760 KB Output is correct
22 Correct 105 ms 14768 KB Output is correct
23 Correct 99 ms 15248 KB Output is correct
24 Correct 95 ms 16716 KB Output is correct
25 Correct 84 ms 15152 KB Output is correct
26 Correct 103 ms 19252 KB Output is correct
27 Correct 164 ms 21152 KB Output is correct
28 Correct 78 ms 16716 KB Output is correct
29 Correct 152 ms 19512 KB Output is correct
30 Correct 69 ms 13600 KB Output is correct
31 Correct 156 ms 20896 KB Output is correct
32 Correct 78 ms 16860 KB Output is correct
33 Correct 88 ms 18624 KB Output is correct
34 Correct 93 ms 17840 KB Output is correct
35 Correct 94 ms 16844 KB Output is correct
36 Correct 83 ms 16308 KB Output is correct
37 Correct 72 ms 14820 KB Output is correct
38 Correct 85 ms 18220 KB Output is correct
39 Correct 120 ms 19784 KB Output is correct
40 Correct 81 ms 17388 KB Output is correct
41 Correct 71 ms 15688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -