Language: C++

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<queue>
using namespace std;
int n,H,W;
const int maxn = 1e3;
const int INF = 1e9;
int labyrinth[maxn][maxn],scnt;
int shortest;
int pshort,sshort,eshort,goal;
bool tf;

struct pt
{
	int x,y;
} soldier[1e5],princess,escape;
char ch;
bool vis[maxn][maxn];

int dfs(int x,int y,int cur_length)
{
	int temp;
	//printf("%d %d, H:%d W:%d\n",x,y,H,W);
	//labyrinth[y][x] = 3;
	vis[y][x] = true;
	if(x>0&&labyrinth[y][x-1]&&!vis[y][x-1])
	{
		if(labyrinth[y][x-1] == goal)
		{
			return cur_length+1;
		}
		if((temp = dfs(x-1,y,cur_length+1))<shortest)
		{
			shortest = temp;
		}
	}
	if(x<W-1&&labyrinth[y][x+1]&&!vis[y][x+1])
	{
		if(labyrinth[y][x+1] == 2)
		{
			return cur_length+1;
		}
		if((temp = dfs(x+1,y,cur_length+1))<shortest)
		{
			shortest = temp;
		}
	}
	if(y>0&&labyrinth[y-1][x]&&!vis[y-1][x])
	{
		if(labyrinth[y-1][x] == 2)
		{
			return cur_length+1;
		}
		if((temp = dfs(x,y-1,cur_length+1))<shortest)
		{
			shortest = temp;
		}
	}
	if(y<H-1&&labyrinth[y+1][x]&&!vis[y+1][x])
	{
		if(labyrinth[y+1][x] == 2)
		{
			return cur_length+1;
		}
		if((temp = dfs(x,y+1,cur_length+1))<shortest)
		{
			shortest = temp;
		}
	}
	return shortest;
}

int main()
{
	ios::sync_with_stdio(false);
	//freopen("1002.txt","r",stdin);
	//freopen("ans.txt","w+",stdout);
	while(~scanf("%d%d",&H,&W))
	{
		tf = true;
		scnt = 0;
		shortest = INF;
		memset(labyrinth,-1,sizeof(labyrinth));
		getchar();
		for(int i = 0; i<H; ++i)
		{
			for(int j = 0; j < W; ++ j)
			{
				while((ch = getchar())=='\n');
				switch(ch)
				{
				case '@':
					princess.x = j;
					princess.y = i,labyrinth[i][j] = 5;
					break;
				case '.':
					labyrinth[i][j] = 1;
					break;
				case '$':
					soldier[scnt].x = j;
					soldier[scnt++].y = i;
					labyrinth[i][j] = 0;
					break;
				case '%':
					labyrinth[i][j] = 2;
					escape.x = j;
					escape.y = i;
					break;
				case '#':
					labyrinth[i][j] = 0;
					break;
				}
			}
		}
		memset(vis,false,sizeof(vis));
		goal = 2;
		pshort = dfs(princess.x,princess.y,0);
		//printf("pshort:%d\n",pshort);

		goal = 5;
		shortest = INF;
		memset(vis,false,sizeof(vis));
		eshort = dfs(escape.x,escape.y,0);
		//printf("eshort:%d\n",eshort);
		if(eshort<pshort)
			pshort = eshort;
		/*for(int i = 0; i<H; ++i)
		{
			for(int j = 0; j < W; ++ j)
			{
				if(i == princess.y&&j == princess.x)
					printf("X");
				else
				printf("%d",labyrinth[i][j]);
			}
			printf("\n");
		}*/
		if(!scnt&&pshort!=INF)
		{
			tf = true;
		}
		else
		{
			if(pshort != INF)
			{
				goal = 2;
				for(int i = 0; i < scnt; ++i)
				{
					memset(vis,false,sizeof(vis));
					shortest = INF;
					sshort = dfs(soldier[i].x,soldier[i].y,0);
					//printf("sshort:%d\n",sshort);
					if(sshort <= pshort)
					{
						tf = false;
						break;
					}
				}

			}
			else
				tf = false;

		}
		if(tf)
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}


	}
}

Compiler output:
a.cc:27:11: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
   27 | } soldier[1e5],princess,escape;
      |           ^~~
a.cc:27:11: error: could not convert '1.0e+5' from 'double' to 'long unsigned int'
   27 | } soldier[1e5],princess,escape;
      |           ^~~
      |           |
      |           double
a.cc:27:11: error: size of array 'soldier' has non-integral type 'double'