Language: C++

#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
const int N=100001,M=200002;
const int INF=0x7f7f7f7f;
struct node {
        int i,value;
        friend bool operator < (node a,node b){
                return a.value > b.value;
        }
};
struct edge{
	int to,value;
	int next;
}mem[M];
priority_queue<node> minq;
int head[N],size=0,dis[N],n,m,start,end,qian[N];
bool vis[N];
void  dijkstra(int start){
        dis[start]=0;
        node tmp={start,0};
        minq.push(tmp);
        while(!minq.empty()){
                tmp=minq.top();
                minq.pop();
                if(vis[tmp.i])continue;
                vis[tmp.i]=true;
                for(int j=head[tmp.i];j!=0;j=mem[j].next){
                		int to=mem[j].to;
                	    if(!vis[to]&&mem[j].value+dis[tmp.i]<dis[to]){
                            	dis[to]=mem[j].value+dis[tmp.i];
                                node tmp2={to,dis[to]};
                                minq.push(tmp2);
                                qian[to] = tmp.i;
                        }
                }
        }
}
int main(){
        memset(head,0,sizeof(head));
        memset(dis,0x7f,sizeof(dis));
        memset(vis,false,sizeof(vis));
        memset(qian,-1,sizeof(qian));
        scanf("%d %d",&n,&m);
        start=1,end=n;
        int u,v,w;
        for(int i=1;i<=m;i++){
                scanf("%d %d",&u,&v);w=1;
                size++;mem[size].to=v;mem[size].value=w;mem[size].next=head[u];head[u]=size;
                size++;mem[size].to=u;mem[size].value=w;mem[size].next=head[v];head[v]=size;
        }
        dijkstra(start);
        for(int i=1;i<=n;i++)
        {
        	if(dis[i]>=2139062143){
        		printf("No");return 0;
			}
		}
		printf("Yes\n");
		for(int i=2;i<=n;i++)
		{
			cout<<qian[i]<<endl;
		}
        return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:17: error: reference to 'end' is ambiguous
   47 |         start=1,end=n;
      |                 ^~~
In file included from /usr/include/c++/14/string:53,
                 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/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
  116 |   template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
      |                                     ^~~
/usr/include/c++/14/bits/range_access.h:115:31: note:                 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
  115 |   template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept;
      |                               ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  106 |     end(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
   85 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
   74 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
In file included from /usr/include/c++/14/bits/range_access.h:36:
/usr/include/c++/14/initializer_list:99:5: note:                 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
   99 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
a.cc:19:37: note:                 'int end'
   19 | int head[N],size=0,dis[N],n,m,start,end,qian[N];
      |                                     ^~~
a.cc:51:17: error: reference to 'size' is ambiguous
   51 |                 size++;mem[size].to=v;mem[size].value=w;mem[size].next=head[u];head[u]=size;
      |                 ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:19:13: note:                 'int size'
   19 | int head[N],size=0,dis[N],n,m,start,end,qian[N];
      |             ^~~~
a.cc:51:28: error: reference to 'size' is ambiguous
   51 |                 size++;mem[size].to=v;mem[size].value=w;mem[size].next=head[u];head[u]=size;
      |                            ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:19:13: note:                 'int size'
   19 | int head[N],size=0,dis[N],n,m,start,end,qian[N];
      |             ^~~~
a.cc:51:43: error: reference to 'size' is ambiguous
   51 |                 size++;mem[size].to=v;mem[size].value=w;mem[size].next=head[u];head[u]=size;
      |                                           ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:19:13: note:                 'int size'
   19 | int head[N],size=0,dis[N],n,m,start,end,qian[N];
      |             ^~~~
a.cc:51:61: error: reference to 'size' is ambiguous
   51 |                 size++;mem[size].to=v;mem[size].value=w;mem[size].next=head[u];head[u]=size;
      |                                                             ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:19:13: note:                 'int size'
   19 | int head[N],size=0,dis[N],n,m,start,end,qian[N];
      |             ^~~~
a.cc:51:88: error: reference to 'size' is ambiguous
   51 |                 size++;mem[size].to=v;mem[size].value=w;mem[size].next=head[u];head[u]=size;
      |                                                                                        ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:19:13: note:                 'int size'
   19 | int head[N],size=0,dis[N],n,m,start,end,qian[N];
      |             ^~~~
a.cc:52:17: error: reference to 'size' is ambiguous
   52 |                 size++;mem[size].to=u;mem[size].value=w;mem[size].next=head[v];head[v]=size;
      |                 ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:19:13: note:                 'int size'
   19 | int head[N],size=0,dis[N],n,m,start,end,qian[N];
      |             ^~~~
a.cc:52:28: error: reference to 'size' is ambiguous
   52 |                 size++;mem[size].to=u;mem[size].value=w;mem[size].next=head[v];head[v]=size;
      |                            ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:19:13: note:                 'int size'
   19 | int head[N],size=0,dis[N],n,m,start,end,qian[N];
      |             ^~~~
a.cc:52:43: error: reference to 'size' is ambiguous
   52 |                 size++;mem[size].to=u;mem[size].value=w;mem[size].next=head[v];head[v]=size;
      |                                           ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:19:13: note:                 'int size'
   19 | int head[N],size=0,dis[N],n,m,start,end,qian[N];
      |             ^~~~
a.cc:52:61: error: reference to 'size' is ambiguous
   52 |                 size++;mem[size].to=u;mem[size].value=w;mem[size].next=head[v];head[v]=size;
      |                                                             ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:19:13: note:                 'int size'
   19 | int head[N],size=0,dis[N],n,m,start,end,qian[N];
      |             ^~~~
a.cc:52:88: error: reference to 'size' is ambiguous
   52 |                 size++;mem[size].to=u;mem[size].value=w;mem[size].next=head[v];head[v]=size;
      |                                                                                        ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc: