Submission #431460

# Submission time Handle Problem Language Result Execution time Memory
431460 2021-06-17T12:01:34 Z _fractal Sky Walking (IOI19_walk) C++14
0 / 100
35 ms 3392 KB
#include "walk.h"
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <iostream>
using namespace std;
 
 
long long min_distance(vector<int> x, vector<int> h, vector<int> l, vector<int> r, vector<int> y, int s, int e) {
	int n = x.size();
	int m = l.size();
	vector<int> g[n], v[n];
	vector<long long> dp(m);
	long long ans = (1LL << 60);
	set<pair<int, int>> is;
	for (int i = 0; i < m; ++i) {
		g[l[i]].push_back(i);
		v[r[i]].push_back(i);
	}
	for (int i = 0; i < n; ++i) {
		for (auto it : g[i]) {
			auto jt = is.lower_bound({y[i], -(1 << 30)});
			dp[it] = (1LL << 60);
			if (i == 0) dp[it] = y[it];
			if (jt != is.end())
				if (dp[jt->second] != (1LL << 60))
					dp[it] = min(dp[it], dp[jt->second] + abs(jt->first - y[it]));
			if (jt != is.begin()) {
				jt = prev(jt);
				if (dp[jt->second] != (1LL << 60))
					dp[it] = min(dp[it], dp[jt->second] + abs(jt->first - y[it]));
			}
			is.insert({y[it], it});
		}
		if (i == n - 1)
			for (auto it : is)
				ans = min(ans, dp[it.second]);
		for (auto it : v[i])
			is.erase({y[it], it});	
	}
	if (ans == (1LL << 60))
		return -1;
	return ans + x[n - 1] - x[0];
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 3392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 3392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -