Submission #983124

#TimeUsernameProblemLanguageResultExecution timeMemory
983124vjudge1사이버랜드 (APIO23_cyberland)C++17
Compilation error
0 ms0 KiB
#include "cyberland.h"

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

double nonol(vector<vector<pair<int, int>>> g, int N, int M, int K, int H, vector<int> arr) {
	vector<bool> used(N), ot(N);
	function<void(int, int)> dfs = [&](int v, int cnt) {
		assert(!used[v]);
		used[v] = true;
		for (auto [to, weight]: g[v]) {
			if (!used[to]) {
				if (arr[to] == 2 && cnt) {
					ot[to] = true;
					dfs(to, cnt - 1);
				} else dfs(to, cnt);
			}
		}
	};
	vector<double> d(N + 1, 1e18);
	d[0] = 0;
	set<pair<double, int>> q;
	q.emplace(d[0], 0);
	while (!q.empty()) {
		int nearest = q.begin()->second;
		q.erase(q.begin());
		for (auto [to, weight]: g[nearest]) {
			double dis = d[nearest] + weight;
			if (ot[to]) dis /= 2;
			if (!arr[to]) dis = 0;
			if (d[to] > dis) {
				q.erase(pair{d[to], to});
				d[to] = dis;
				q.emplace(d[to], to);
			}
		}
	}
        if (d[H] == 1e18) d[H] = -1;
	return d[H];
}

double s1(vector<vector<pair<int, int>>> g, int N, int M, int K, int H, vector<int> arr) {
	double dis = 1e18;
	bool can = false;
	double zap;
	int u;
	for (auto [to, weight]: g[0]) {
		if (to == H) {
			dis = min(dis, weight);
		} else can = true, zap = weight, u = to;
	}
	if (can) {
		double w;
		can = false;
		for (auto [to, weight]: g[u]) {
			if (to == H) can = true, w = weight;
		}
		if (can) {
			if (arr[u] == 0) dis = min(dis, w);
			else if (arr[u] == 1) dis = min(dis, w + zap);
			else dis = min(dis, zap / 2. + w);
		}
	}
	if (dis == 1e18) dis = -1;
	return dis;
}

double s4(vector<vector<pair<int, int>>> g, int N, int M, int K, int H, vector<int> arr) {return -1;}
double yesnol(vector<vector<pair<int, int>>> g, int N, int M, int K, int H, vector<int> arr) {return -1;}

double solve(int N, int M, int K, int H, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) {
    vector<vector<pair<int, int>>> g(N);
    bool is2 = true;
    for (int i = 0; i < M; ++i) {
		g[x[i]].emplace_back(y[i], c[i]);
		g[y[i]].emplace_back(x[i], c[i]);
		if (x[i] != i || y[i] != i + 1) is2 = false;
	}
	if (N <= 3) return s1(g, N, M, K, H, arr);
	else if (is2) return s4(g, N, M, K, H, arr);
	else if (find(arr.begin(), arr.end(), 0LL) == arr.end()) return nonol(g, N, M, K, H, arr);
	else return yesnol(g, N, M, K, H, arr);
}

Compilation message (stderr)

cyberland.cpp: In function 'double s1(std::vector<std::vector<std::pair<int, int> > >, int, int, int, int, std::vector<int>)':
cyberland.cpp:49:25: error: no matching function for call to 'min(double&, std::tuple_element<1, std::pair<int, int> >::type&)'
   49 |    dis = min(dis, weight);
      |                         ^
In file included from /usr/include/c++/10/vector:60,
                 from cyberland.h:1,
                 from cyberland.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
cyberland.cpp:49:25: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'std::tuple_element<1, std::pair<int, int> >::type' {aka 'int'})
   49 |    dis = min(dis, weight);
      |                         ^
In file included from /usr/include/c++/10/vector:60,
                 from cyberland.h:1,
                 from cyberland.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
cyberland.cpp:49:25: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'std::tuple_element<1, std::pair<int, int> >::type' {aka 'int'})
   49 |    dis = min(dis, weight);
      |                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from cyberland.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
cyberland.cpp:49:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'double'
   49 |    dis = min(dis, weight);
      |                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from cyberland.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
cyberland.cpp:49:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'double'
   49 |    dis = min(dis, weight);
      |                         ^