Language: C++

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<functional>
#include<queue>
#include<vector>

using namespace std;

int n,dx,dy,hx,hy;
int cx[20],cy[20];
short dp[1<<20][21];

int main(void){
	while(1){
		scanf("%d %d %d %d %d",&n,&hx,&hy,&dx,&dy);
		if(n+hx+hy+dx+dy==0)break;
		for(int i=0;i<n;i++){
			scanf("%d %d",&cx[i],&cy[i]);
		}
		cx[n]=hx,cy[n]=hy;
		memset(dp,-1,sizeof(dp));
		dp[0][n]=0;
		bool flag=false;
		for(int i=0;i<1<<n;i++){
			if(flag)continue;
			for(int j=0;j<=n;j++){
				if(dp[i][j]!=-1){
					for(int k=0;k<n;k++){
						if((i>>k) & 1)continue;
						int move=abs(cx[j]-cx[k])+abs(cy[j]-cy[k]);
						int ng=abs(dx-cx[k])+abs(dy-cy[k]);
						if(dp[i][j]+move>=ng)continue;	
						dp[i|(1<<k)][k]=min(dp[i|(1<<k)][k],dp[i][j]+move);
						if(dp[i|(1<<k)][k]==-1)dp[i|(1<<k)][k]=dp[i][j]+move;
						if(i|(1<<k)==(1<<n)-1)flag=true;
					}
				}
			}
		}
		printf("%s\n",flag?"YES":"NO");
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:68: error: no matching function for call to 'min(short int&, int)'
   34 |                                                 dp[i|(1<<k)][k]=min(dp[i|(1<<k)][k],dp[i][j]+move);
      |                                                                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from a.cc:2:
/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:34:68: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   34 |                                                 dp[i|(1<<k)][k]=min(dp[i|(1<<k)][k],dp[i][j]+move);
      |                                                                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:34:68: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   34 |                                                 dp[i|(1<<k)][k]=min(dp[i|(1<<k)][k],dp[i][j]+move);
      |                                                                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~