Submission #612674

# Submission time Handle Problem Language Result Execution time Memory
612674 2022-07-29T20:16:12 Z morete Sky Walking (IOI19_walk) C++17
Compilation error
0 ms 0 KB
#include "bits/stdc++.h"
#include "walk.h"
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<algorithm>

using namespace std;

#define pb push_back
#define snd second
#define fst first

const ll INF = 1e18;

typedef long long int ll;

int n, m;
map<ll, ll> dst; // altura, custo vertical
map<ll, vector<int>> com, fim;

long long min_distance(std::vector<int> x, std::vector<int> h, std::vector<int> l, std::vector<int> r, std::vector<int> y, int s, int g) {
	n = x.size();
	m = l.size();

	for (int i = 0; i < m; i++){ // altura tem que bater pelo enunciado
		com[l[i]].push_back(y[i]);
		fim[r[i]].push_back(y[i]); // sei onde começa e onde acaba
	}

	// tomar cuidado com inicio e fim na mesma altura na mesma barra


	ll ans = INF; //INF


	dst[0] = 0; // altura zero no inicio
	fim[x[0]].pb(0); // depois não é mais válido

	for (int i = 0; i < n; i++){
		set<int> stay;

		for (auto e : com[x[0]]){
			if (dst.count(e)) 
				stay.insert(e); // não apaga essa altura
				// pode manter o mesmo valor
			else{
				auto it = dst.lower_bound(e);
				auto dit = it--;
				if (dit != dst.begin()) // se eeiste
					dit--;

				ll min = INF; //INF

				if ((it != dst.end()) and ((*it).fst <= h[i])){ // caminho válido
					min = (*it).snd + abs((*it).fst - e);
				}

				if ((dit != dst.end()) and ((*dit).fst <= h[i])){ // caminho válido
					min = (*dit).snd + abs((*dit).fst - e);
				}

				dst[e] = min;
			}

		}

		if (i == n - 1){
			for (auto e : dst)
				ans = min(ans, e.fst + e.snd);

		} 

		for (auto e : fim[x[0]])
			if (!stay.count(e))
				dst.erase(e);
	}

	return ans;
}

// signed main(){
// 	int n, m;
// 	assert(2 == scanf("%d%d", &n, &m));
// 	vector<int> x(n), h(n);
// 	for (int i = 0; i < n; i++)
// 		assert(2 == scanf("%d%d", &x[i], &h[i]));
// 	vector<int> l(m), r(m), y(m);
// 	for (int i = 0; i < m; i++)
// 		assert(3 == scanf("%d%d%d", &l[i], &r[i], &y[i]));
// 	int s, g;
// 	assert(2 == scanf("%d%d", &s, &g));
// 	fclose(stdin);

// 	long long result = min_distance(x, h, l, r, y, s, g);

// 	printf("%lld\n", result);
// 	fclose(stdout);
// 	return 0;
// }

Compilation message

walk.cpp:16:7: error: 'll' does not name a type
   16 | const ll INF = 1e18;
      |       ^~
walk.cpp: In function 'long long int min_distance(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, int, int)':
walk.cpp:36:11: error: 'INF' was not declared in this scope
   36 |  ll ans = INF; //INF
      |           ^~~