Language: C++

#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <queue>
#include <algorithm>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);

class Graph{
	private:
	vvi Gpro,Gd;
	vvp Glist;
	int GV,GE;
	public:
	Graph(int x,int y,bool z){
		GV=x;
		GE=y;
		Gd=vvi(x,vi(x,inf));
		if(z) Gpro=vvi(x,vi(x,inf));
		else Glist=vvp(x);
	}
	void Gpro_add(int x,int y,int z){
		Gpro[x][y]=z;
		Gpro[y][x]=z;
	}
	void Glist_add(int x,int y,int z){
		Glist[x].push_back(P(y,z));
		Glist[y].push_back(P(x,z));
	}
	void Gd_add(int x,int y,int z){
		Gd[x][y]=z;
	}
	int open(int x,int y){
		return Gd[x][y];
	}
	void DIJplus(int x){
		priority_queue<P> que;
		Gd[x][x]=0;
		que.push(P(0,x));
		while(!que.empty()){
			P p=que.top();
			p.first*=-1;
			que.pop();
			int v=p.second;
			if(Gd[x][v]<p.first) continue;
			for(int i=0;i<Glist[v].size();i++){
				P e=Glist[v][i];
				if(Gd[x][e.first]>Gd[x][v]+e.second){
					Gd[x][e.first]=Gd[x][v]+e.second;
					que.push(P(-1*Gd[x][e.first],e.first));
				}
			}
		}
	}
	void BELLMAN(int x){
		Gd[x][x]=0;
		while(1){
			bool update=1;
			for(int i=0;i<GV;i++){
				for(int j=0;j<Glist[i].size();j++){
					P e=P(Glist[i][j].first,Glist[i][j].second);
					if(Gd[x][i]!=inf&&Gd[x][e.first]>Gd[x][i]+e.second){
						Gd[x][e.first]=Gd[x][i]+e.second;
						update=0;
					}
				}
			}
			if(update) break;
		}
	}
	bool FNL(int x){
		Gd[x][x]=0;
		for(int i=0;i<GV;i++){
			for(int j=0;j<GV;j++){
				for(int k=0;k<Glist[j].size();k++){
					P e=P(Glist[j][k].first,Glist[j][k].second);
					if(Gd[x][j]!=inf&&Gd[x][e.first]>Gd[x][j]+e.second){
						Gd[x][e.first]=Gd[x][j]+e.second;
						if(i==GV-1) return 1;
					}
				}
			}
		}
		Gd=vvi(GV,vi(GV,inf));
		return 0;
	}
	void WARSHALL(){
		for(int i=0;i<GV;i++){
			for(int j=0;j<GV;j++){
				for(int k=0;k<GV;k++) Gd[i][j]=min(Gd[i][j],Gd[i][k]+Gd[k][j]);
			}
		}
	}
	int PRIM(){
		int Gans=0;
		vi mincost(GV,inf);
		vector<bool> used(GV,1);
		mincost[0]=0;
		while(1){
			int v=-1;
			for(int i=0;i<GV;i++){
				if(used[i]&&(v==-1||mincost[i]<mincost[v])) v=i;
			}
			if(v==-1) break;
			used[v]=0;
			Gans+=mincost[v];
			for(int i=0;i<Glist[v].size();i++){
				mincost[i]=min(mincost[i],Glist[v][i]);
			}
		}
		return Gans;
	}
};


int V,E;

int main(){
	cin>>V>>E;
	Graph gra(V,E,0);
	for(int i=0;i<E;i++){
		int s,t,d;
		cin>>s>>t>>d;
		gra.Glist_add(s,t,d);
	}
	cout<<gra.PRIM()<<endl;
}

Compiler output:
a.cc: In member function 'int Graph::PRIM()':
a.cc:119:47: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, __gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type&)'
  119 |                                 mincost[i]=min(mincost[i],Glist[v][i]);
      |                                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 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:119:47: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'})
  119 |                                 mincost[i]=min(mincost[i],Glist[v][i]);
      |                                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~
/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,
                 from a.cc:6:
/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:119:47: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  119 |                                 mincost[i]=min(mincost[i],Glist[v][i]);
      |                                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~