Language: C++

/*input
3 4 10 40
*/

#include <bits/stdc++.h>
using namespace std;
 
 
 
#define int long long int
#define rep(i,n) \
    for(int i = 0; i < n; i++)
#define rep2(i, a, b) \
    for(int i = a; i < b; i++)
#define all(c) \
    c.begin(), c.end()
#define init(arr, num) \
    memset(arr, num, sizeof(arr))
#define fast\
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inputFile \
    freopen("input.txt", "r", stdin); 
#define outputFile \
    freopen("output.txt", "w", stdout);
#define modM 1000000007
#define PI 3.1415926535897932
 
#ifdef Voneone
#define TRACE
#endif
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
 
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); 
    cout.write(names, comma - names) << " : " << arg1 << " | "; 
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
typedef unordered_set<int> usi;
 

 


 
void solve() 
{ 
 
cin>>n>>m;
vector <int> v[n+1];
int par[n+1];
init(par,0);
for(i=0;i<m;i++)
{
    cin>>j>>k;
    v[j].push_back(k);
    v[k].push_back(j);

}  

queue<int> q;
int vis[n+1];
init(vis,0);
q.push(1);
vis[1]=1;
par[1]=1;

while(!q.empty())
{
    k=q.front();
    q.pop();
    for(i=0;i<v[k].size();i++)
    {
        if(vis[v[k][i]]==0)
        {vis[v[k][i]]=1;
            par[v[k][i]]=k;


            q.push(v[k][i]);


        }
    }
}
for(i=2;i<=n;i++)
{if(par[i]==0)
    {
        cout<<"No";
        return;
   // cout<<par[i]<<" ";
    }
}
cout<<"Yes\n";
for(i=2;i<=n;i++)
{
    cout<<par[i]<<"\n";
}

    

 
} 
 
 
 
 
signed main()
{
 
    
    #ifdef _DEBUG
    inputFile;
    #endif
    #ifndef __CINP
    fast;
    #endif
 
 
    int T = 1;
    // cin >> T;
    while(T--){
        solve();
        cout << endl;
        
        
 
    }
    
    
    return 0;
 
}
 



Compiler output:
a.cc: In function 'void solve()':
a.cc:63:6: error: 'n' was not declared in this scope; did you mean 'yn'?
   63 | cin>>n>>m;
      |      ^
      |      yn
a.cc:63:9: error: 'm' was not declared in this scope; did you mean 'tm'?
   63 | cin>>n>>m;
      |         ^
      |         tm
a.cc:66:6: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
   66 | init(par,0);
      |      ^~~
a.cc:18:12: note: in definition of macro 'init'
   18 |     memset(arr, num, sizeof(arr))
      |            ^~~
In file included from /usr/include/c++/14/pstl/glue_algorithm_defs.h:15,
                 from /usr/include/c++/14/algorithm:86,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:5:
/usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here
   43 | _GLIBCXX17_INLINE constexpr parallel_policy par{};
      |                                             ^~~
a.cc:67:5: error: 'i' was not declared in this scope; did you mean 'vi'?
   67 | for(i=0;i<m;i++)
      |     ^
      |     vi
a.cc:69:10: error: 'j' was not declared in this scope; did you mean 'jn'?
   69 |     cin>>j>>k;
      |          ^
      |          jn
a.cc:69:13: error: 'k' was not declared in this scope
   69 |     cin>>j>>k;
      |             ^
a.cc:70:5: error: 'v' was not declared in this scope; did you mean 'vi'?
   70 |     v[j].push_back(k);
      |     ^
      |     vi
a.cc:77:6: error: 'vis' was not declared in this scope; did you mean 'vi'?
   77 | init(vis,0);
      |      ^~~
a.cc:18:12: note: in definition of macro 'init'
   18 |     memset(arr, num, sizeof(arr))
      |            ^~~
a.cc:84:5: error: 'k' was not declared in this scope
   84 |     k=q.front();
      |     ^
a.cc:86:9: error: 'i' was not declared in this scope
   86 |     for(i=0;i<v[k].size();i++)
      |         ^
a.cc:86:15: error: 'v' was not declared in this scope
   86 |     for(i=0;i<v[k].size();i++)
      |               ^
a.cc:99:5: error: 'i' was not declared in this scope
   99 | for(i=2;i<=n;i++)
      |     ^
a.cc:108:5: error: 'i' was not declared in this scope
  108 | for(i=2;i<=n;i++)
      |     ^