Language: C++



int light[100005];
vector<deque<int>> miti(100005);

void f(deque<int> &v, int from)
{
}

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


  rep(i, m) {
    int a, b;
    cin >> a >> b;
    miti[a].push_back(b);
    miti[b].push_back(a);
  }

  deque<pair<int, int>> next;
  for (int x : miti[1]) {
    next.push_back(make_pair(x, 1));
  }
  do {
    for(pair<int, int> x : next) {
      next.pop_front();
      if (light[x.first] == 0) {
        light[x.first] = x.second;
        for (int y : miti[x.first]) {
          if (light[y] == 0) {
            next.push_back(make_pair(y, x.first));
          }
        }
      }
    }
  } while (!next.empty());

  bool ok = true;
  for (int i = 2; i <= n; i++) {
    if (light[i] == 0) ok = false;
  }
  if (!ok) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
    for (int i = 2; i <= n; i++) {
      cout << light[i] << endl;
    }
  }
}


Compiler output:
a.cc:4:1: error: 'vector' does not name a type
    4 | vector<deque<int>> miti(100005);
      | ^~~~~~
a.cc:6:6: error: variable or field 'f' declared void
    6 | void f(deque<int> &v, int from)
      |      ^
a.cc:6:8: error: 'deque' was not declared in this scope
    6 | void f(deque<int> &v, int from)
      |        ^~~~~
a.cc:6:14: error: expected primary-expression before 'int'
    6 | void f(deque<int> &v, int from)
      |              ^~~
a.cc:6:23: error: expected primary-expression before 'int'
    6 | void f(deque<int> &v, int from)
      |                       ^~~
a.cc: In function 'int main()':
a.cc:12:3: error: 'll' was not declared in this scope
   12 |   ll n, m;
      |   ^~
a.cc:13:3: error: 'cin' was not declared in this scope
   13 |   cin >> n >> m;
      |   ^~~
a.cc:13:10: error: 'n' was not declared in this scope
   13 |   cin >> n >> m;
      |          ^
a.cc:13:15: error: 'm' was not declared in this scope
   13 |   cin >> n >> m;
      |               ^
a.cc:16:7: error: 'i' was not declared in this scope
   16 |   rep(i, m) {
      |       ^
a.cc:16:3: error: 'rep' was not declared in this scope
   16 |   rep(i, m) {
      |   ^~~
a.cc:23:3: error: 'deque' was not declared in this scope
   23 |   deque<pair<int, int>> next;
      |   ^~~~~
a.cc:23:9: error: 'pair' was not declared in this scope
   23 |   deque<pair<int, int>> next;
      |         ^~~~
a.cc:23:14: error: expected primary-expression before 'int'
   23 |   deque<pair<int, int>> next;
      |              ^~~
a.cc:24:16: error: 'miti' was not declared in this scope
   24 |   for (int x : miti[1]) {
      |                ^~~~
a.cc:25:5: error: 'next' was not declared in this scope
   25 |     next.push_back(make_pair(x, 1));
      |     ^~~~
a.cc:25:20: error: 'make_pair' was not declared in this scope
   25 |     next.push_back(make_pair(x, 1));
      |                    ^~~~~~~~~
a.cc:28:14: error: expected primary-expression before 'int'
   28 |     for(pair<int, int> x : next) {
      |              ^~~
a.cc:39:3: error: expected primary-expression before '}' token
   39 |   } while (!next.empty());
      |   ^
a.cc:38:6: error: expected ';' before '}' token
   38 |     }
      |      ^
      |      ;
   39 |   } while (!next.empty());
      |   ~   
a.cc:39:3: error: expected primary-expression before '}' token
   39 |   } while (!next.empty());
      |   ^
a.cc:38:6: error: expected ')' before '}' token
   38 |     }
      |      ^
      |      )
   39 |   } while (!next.empty());
      |   ~   
a.cc:28:8: note: to match this '('
   28 |     for(pair<int, int> x : next) {
      |        ^
a.cc:39:3: error: expected primary-expression before '}' token
   39 |   } while (!next.empty());
      |   ^
a.cc:39:13: error: 'next' was not declared in this scope
   39 |   } while (!next.empty());
      |             ^~~~
a.cc:46:5: error: 'cout' was not declared in this scope
   46 |     cout << "No" << endl;
      |     ^~~~
a.cc:46:21: error: 'endl' was not declared in this scope
   46 |     cout << "No" << endl;
      |                     ^~~~
a.cc:48:5: error: 'cout' was not declared in this scope
   48 |     cout << "Yes" << endl;
      |     ^~~~
a.cc:48:22: error: 'endl' was not declared in this scope
   48 |     cout << "Yes" << endl;
      |                      ^~~~