Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N;
	cin >> N;

	pair<int, int> X[100001], Y[100001];
	rep1(i, N) {
		int x, y;
		cin >> x >> y;
		X[i] = make_pair(x, i);
		Y[i] = make_pair(y, i);
	}
	sort(X + 1, X + N + 1);
	sort(Y + 1, Y + N + 1);

	vector<pair<int, int>> eda[100001];

	rep1(i, N - 1) {
		eda[X[i].second].push_back(make_pair(X[i + 1].second, abs(X[i + 1].first - X[i].first)));
		eda[X[i + 1].second].push_back(make_pair(X[i].second, abs(X[i + 1].first - X[i].first)));
		eda[Y[i].second].push_back(make_pair(Y[i + 1].second, abs(Y[i + 1].first - Y[i].first)));
		eda[Y[i + 1].second].push_back(make_pair(Y[i].second, abs(Y[i + 1].first - Y[i].first)));
	}

	ll kyori[100001] = {};
	ll edanagasa[100001] = {};
	rep1(i, N) kyori[i] = 1e18;
	vector<pair<int, pair<ll, int>>> que;
	que.push_back(make_pair(1, make_pair(1, 1)));

	while (que.size()) {
		vector<pair<int, pair<ll, int>>> que2;
		for (auto itr : que) {
			if (kyori[itr.first] > itr.second.first) {
				kyori[itr.first] = itr.second.first;
				edanagasa[itr.first] = itr.second.second;
				for (auto itr2 : eda[itr.first]) {
					que2.push_back(make_pair(itr2.first, make_pair(itr2.second + itr.second.first, itr2.second)));
				}
			}
			else if (kyori[itr.first] == itr.second.first) {
				edanagasa[itr.first] = min(edanagasa[itr.first], itr.second.second);
			}
		}
		que = que2;
	}

	ll kotae = 0;
	rep1(i, N - 1) {
		kotae += edanagasa[i + 1];
	}
	co(kotae);

	Would you please return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:59:59: error: no matching function for call to 'min(ll&, int&)'
   59 |                                 edanagasa[itr.first] = min(edanagasa[itr.first], itr.second.second);
      |                                                        ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:59:59: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   59 |                                 edanagasa[itr.first] = min(edanagasa[itr.first], itr.second.second);
      |                                                        ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:59:59: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   59 |                                 edanagasa[itr.first] = min(edanagasa[itr.first], itr.second.second);
      |                                                        ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~