Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll n,m;cin>>n>>m;

  vector<Edge> G(n+m);
  vector<ll> dist(n);

  vector<ll> ans(n+1);

  int a,b;  
  rep(i,n+m-1){
    cin>>a>>b;
    a--;
    b--;
    G[i].from=a;
    G[i].to=b;

    if(dist[G[i].from]+1>dist[G[i].to]){
      dist[G[i].to]=dist[G[i].from]+1;
      ans[G[i].to+1]=G[i].from+1;
    }
  }

  rep(i,n+m-1){
    if(dist[G[i].from]+1>dist[G[i].to]){
      dist[G[i].to]=dist[G[i].from]+1;
      ans[G[i].to+1]=G[i].from+1;
    }
  }

  rep(i,n+m-1){
    if(dist[G[i].from]+1>dist[G[i].to]){
      dist[G[i].to]=dist[G[i].from]+1;
      ans[G[i].to+1]=G[i].from+1;
    }
  }

  rep(i,n+m-1){
    if(dist[G[i].from]+1>dist[G[i].to]){
      dist[G[i].to]=dist[G[i].from]+1;
      ans[G[i].to+1]=G[i].from+1;
    }
  }

  rep(i,n+m-1){
    if(dist[G[i].from]+1>dist[G[i].to]){
      dist[G[i].to]=dist[G[i].from]+1;
      ans[G[i].to+1]=G[i].from+1;
    }
  }

  rep(i,n+m-1){
    if(dist[G[i].from]+1>dist[G[i].to]){
      dist[G[i].to]=dist[G[i].from]+1;
      ans[G[i].to+1]=G[i].from+1;
    }
  }

  rep(i,n+m-1){
    if(dist[G[i].from]+1>dist[G[i].to]){
      dist[G[i].to]=dist[G[i].from]+1;
      ans[G[i].to+1]=G[i].from+1;
    }
  }

  FOR(i,1,n+1){
    cout<<ans[i]<<endl;
  }

  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:32:10: error: 'Edge' was not declared in this scope
   32 |   vector<Edge> G(n+m);
      |          ^~~~
a.cc:32:14: error: template argument 1 is invalid
   32 |   vector<Edge> G(n+m);
      |              ^
a.cc:32:14: error: template argument 2 is invalid
a.cc:42:6: error: invalid types 'int[int]' for array subscript
   42 |     G[i].from=a;
      |      ^
a.cc:43:6: error: invalid types 'int[int]' for array subscript
   43 |     G[i].to=b;
      |      ^
a.cc:45:14: error: invalid types 'int[int]' for array subscript
   45 |     if(dist[G[i].from]+1>dist[G[i].to]){
      |              ^
a.cc:45:32: error: invalid types 'int[int]' for array subscript
   45 |     if(dist[G[i].from]+1>dist[G[i].to]){
      |                                ^
a.cc:46:13: error: invalid types 'int[int]' for array subscript
   46 |       dist[G[i].to]=dist[G[i].from]+1;
      |             ^
a.cc:46:27: error: invalid types 'int[int]' for array subscript
   46 |       dist[G[i].to]=dist[G[i].from]+1;
      |                           ^
a.cc:47:12: error: invalid types 'int[int]' for array subscript
   47 |       ans[G[i].to+1]=G[i].from+1;
      |            ^
a.cc:47:23: error: invalid types 'int[int]' for array subscript
   47 |       ans[G[i].to+1]=G[i].from+1;
      |                       ^
a.cc:52:14: error: invalid types 'int[int]' for array subscript
   52 |     if(dist[G[i].from]+1>dist[G[i].to]){
      |              ^
a.cc:52:32: error: invalid types 'int[int]' for array subscript
   52 |     if(dist[G[i].from]+1>dist[G[i].to]){
      |                                ^
a.cc:53:13: error: invalid types 'int[int]' for array subscript
   53 |       dist[G[i].to]=dist[G[i].from]+1;
      |             ^
a.cc:53:27: error: invalid types 'int[int]' for array subscript
   53 |       dist[G[i].to]=dist[G[i].from]+1;
      |                           ^
a.cc:54:12: error: invalid types 'int[int]' for array subscript
   54 |       ans[G[i].to+1]=G[i].from+1;
      |            ^
a.cc:54:23: error: invalid types 'int[int]' for array subscript
   54 |       ans[G[i].to+1]=G[i].from+1;
      |                       ^
a.cc:59:14: error: invalid types 'int[int]' for array subscript
   59 |     if(dist[G[i].from]+1>dist[G[i].to]){
      |              ^
a.cc:59:32: error: invalid types 'int[int]' for array subscript
   59 |     if(dist[G[i].from]+1>dist[G[i].to]){
      |                                ^
a.cc:60:13: error: invalid types 'int[int]' for array subscript
   60 |       dist[G[i].to]=dist[G[i].from]+1;
      |             ^
a.cc:60:27: error: invalid types 'int[int]' for array subscript
   60 |       dist[G[i].to]=dist[G[i].from]+1;
      |                           ^
a.cc:61:12: error: invalid types 'int[int]' for array subscript
   61 |       ans[G[i].to+1]=G[i].from+1;
      |            ^
a.cc:61:23: error: invalid types 'int[int]' for array subscript
   61 |       ans[G[i].to+1]=G[i].from+1;
      |                       ^
a.cc:66:14: error: invalid types 'int[int]' for array subscript
   66 |     if(dist[G[i].from]+1>dist[G[i].to]){
      |              ^
a.cc:66:32: error: invalid types 'int[int]' for array subscript
   66 |     if(dist[G[i].from]+1>dist[G[i].to]){
      |                                ^
a.cc:67:13: error: invalid types 'int[int]' for array subscript
   67 |       dist[G[i].to]=dist[G[i].from]+1;
      |             ^
a.cc:67:27: error: invalid types 'int[int]' for array subscript
   67 |       dist[G[i].to]=dist[G[i].from]+1;
      |                           ^
a.cc:68:12: error: invalid types 'int[int]' for array subscript
   68 |       ans[G[i].to+1]=G[i].from+1;
      |            ^
a.cc:68:23: error: invalid types 'int[int]' for array subscript
   68 |       ans[G[i].to+1]=G[i].from+1;
      |                       ^
a.cc:73:14: error: invalid types 'int[int]' for array subscript
   73 |     if(dist[G[i].from]+1>dist[G[i].to]){
      |              ^
a.cc:73:32: error: invalid types 'int[int]' for array subscript
   73 |     if(dist[G[i].from]+1>dist[G[i].to]){
      |                                ^
a.cc:74:13: error: invalid types 'int[int]' for array subscript
   74 |       dist[G[i].to]=dist[G[i].from]+1;
      |             ^
a.cc:74:27: error: invalid types 'int[int]' for array subscript
   74 |       dist[G[i].to]=dist[G[i].from]+1;
      |                           ^
a.cc:75:12: error: invalid types 'int[int]' for array subscript
   75 |       ans[G[i].to+1]=G[i].from+1;
      |            ^
a.cc:75:23: error: invalid types 'int[int]' for array subscript
   75 |       ans[G[i].to+1]=G[i].from+1;
      |                       ^
a.cc:80:14: error: invalid types 'int[int]' for array subscript
   80 |     if(dist[G[i].from]+1>dist[G[i].to]){
      |              ^
a.cc:80:32: error: invalid types 'int[int]' for array subscript
   80 |     if(dist[G[i].from]+1>dist[G[i].to]){
      |                                ^
a.cc:81:13: error: invalid types 'int[int]' for array subscript
   81 |       dist[G[i].to]=dist[G[i].from]+1;
      |             ^
a.cc:81:27: error: invalid types 'int[int]' for array subscript
   81 |       dist[G[i].to]=dist[G[i].from]+1;
      |                           ^
a.cc:82:12: error: invalid types 'int[int]' for array subscript
   82 |       ans[G[i].to+1]=G[i].from+1;
      |            ^
a.cc:82:23: error: invalid types 'int[int]' for array subscript
   82 |       ans[G[i].to+1]=G[i].from+1;
      |                       ^
a.cc:87:14: error: invalid types 'int[int]' for array subscript
   87 |     if(dist[G[i].from]+1>dist[G[i].to]){
      |              ^
a.cc:87:32: error: invalid types 'int[int]' for array subscript
   87 |     if(dist[G[i].from]+1>dist[G[i].to]){
      |                                ^
a.cc:88:13: error: invalid types 'int[int]' for array subscript
   88 |       dist[G[i].to]=dist[G[i].from]+1;
      |             ^
a.cc:88:27: error: invalid types 'int[int]' for array subscript
   88 |       dist[G[i].to]=dist[G[i].from]+1;
      |                           ^
a.cc:89:12: error: invalid types 'int[int]' for array subscript
   89 |       ans[G[i].to+1]=G[i].from+1;
      |            ^
a.cc:89:23: error: invalid types 'int[int]' for array subscript
   89 |       ans[G[i].to+1]=G[i].from+1;
      |                       ^