Language: C++

#include<stack>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;
int n;
vector<int> G[MAX];
int color[MAX];
??
void dfs(int r,int c){
????????stack<int> S;
????????S.push(r);
????????color[r] = c;
????????while (!S.empty()){
????????????????int u = S.top(); S.pop();
????????????????for (int i = 0; i < G[u].size(); i++){
????????????????????????int v = G[u][i];
????????????????????????if (color[v] == NIL){
????????????????????????????????color[v] = c;
????????????????????????????????S.push(v);
????????????????????????}
????????????????}
????????}
}
void assignColor(){
????????int id = 1;
????????for (int i = 0; i < n; i++) color[i] = NIL;
????????for (int u = 0; u < n; u++){
????????????????if (color[u] == NIL) dfs(u, id++);
????????}
}
??
??
int main(){
????????int s, t, m, q;
????????cin >> n >> m;
????????for (int i = 0; i < m; i++){
????????????????cin >> s >> t;
????????????????G[s].push_back(t);
????????????????G[t].push_back(s);
????????}
????????assignColor();
????????cin >> q;
??
????????for (int i = 0; i < q; i++){
????????????????cin >> s >> t;
????????????????if (color[s] == color[t]){
????????????????????????cout << "yes" << endl;
????????????????}
????????????????else {
????????????????????????cout << "no" << endl;
????????????????}
????????}
????????return 0;
}

Compiler output:
a.cc:12:1: error: expected unqualified-id before '?' token
   12 | ??
      | ^
a.cc: In function 'void assignColor()':
a.cc:29:1: error: expected primary-expression before '?' token
   29 | ????????int id = 1;
      | ^
a.cc:29:2: error: expected primary-expression before '?' token
   29 | ????????int id = 1;
      |  ^
a.cc:29:3: error: expected primary-expression before '?' token
   29 | ????????int id = 1;
      |   ^
a.cc:29:4: error: expected primary-expression before '?' token
   29 | ????????int id = 1;
      |    ^
a.cc:29:5: error: expected primary-expression before '?' token
   29 | ????????int id = 1;
      |     ^
a.cc:29:6: error: expected primary-expression before '?' token
   29 | ????????int id = 1;
      |      ^
a.cc:29:7: error: expected primary-expression before '?' token
   29 | ????????int id = 1;
      |       ^
a.cc:29:8: error: expected primary-expression before '?' token
   29 | ????????int id = 1;
      |        ^
a.cc:29:9: error: expected primary-expression before 'int'
   29 | ????????int id = 1;
      |         ^~~
a.cc:29:9: error: expected ':' before 'int'
   29 | ????????int id = 1;
      |         ^~~
      |         :
a.cc:29:9: error: expected primary-expression before 'int'
   29 | ????????int id = 1;
      |         ^~~
a.cc:29:9: error: expected ':' before 'int'
   29 | ????????int id = 1;
      |         ^~~
      |         :
a.cc:29:9: error: expected primary-expression before 'int'
   29 | ????????int id = 1;
      |         ^~~
a.cc:29:9: error: expected ':' before 'int'
   29 | ????????int id = 1;
      |         ^~~
      |         :
a.cc:29:9: error: expected primary-expression before 'int'
   29 | ????????int id = 1;
      |         ^~~
a.cc:29:9: error: expected ':' before 'int'
   29 | ????????int id = 1;
      |         ^~~
      |         :
a.cc:29:9: error: expected primary-expression before 'int'
   29 | ????????int id = 1;
      |         ^~~
a.cc:29:9: error: expected ':' before 'int'
   29 | ????????int id = 1;
      |         ^~~
      |         :
a.cc:29:9: error: expected primary-expression before 'int'
   29 | ????????int id = 1;
      |         ^~~
a.cc:29:9: error: expected ':' before 'int'
   29 | ????????int id = 1;
      |         ^~~
      |         :
a.cc:29:9: error: expected primary-expression before 'int'
   29 | ????????int id = 1;
      |         ^~~
a.cc:29:9: error: expected ':' before 'int'
   29 | ????????int id = 1;
      |         ^~~
      |         :
a.cc:29:9: error: expected primary-expression before 'int'
   29 | ????????int id = 1;
      |         ^~~
a.cc:29:9: error: expected ':' before 'int'
   29 | ????????int id = 1;
      |         ^~~
      |         :
a.cc:29:9: error: expected primary-expression before 'int'
   29 | ????????int id = 1;
      |         ^~~
a.cc:30:1: error: expected primary-expression before '?' token
   30 | ????????for (int i = 0; i < n; i++) color[i] = NIL;
      | ^
a.cc:30:2: error: expected primary-expression before '?' token
   30 | ????????for (int i = 0; i < n; i++) color[i] = NIL;
      |  ^
a.cc:30:3: error: expected primary-expression before '?' token
   30 | ????????for (int i = 0; i < n; i++) color[i] = NIL;
      |   ^
a.cc:30:4: error: expected primary-expression before '?' token
   30 | ????????for (int i = 0; i < n; i++) color[i] = NIL;
      |    ^
a.cc:30:5: error: expected primary-expression before '?' token
   30 | ????????for (int i = 0; i < n; i++) color[i] = NIL;
      |     ^
a.cc:30:6: error: expected primary-expression before '?' token
   30 | ????????for (int i = 0; i < n; i++) color[i] = NIL;
      |      ^
a.cc:30:7: error: expected primary-expression before '?' token
   30 | ????????for (int i = 0; i < n; i++) color[i] = NIL;
      |       ^
a.cc:30:8: error: expected primary-expression before '?' token
   30 | ????????for (int i = 0; i < n; i++) color[i] = NIL;
      |        ^
a.cc:30:9: error: expected primary-expression before 'for'
   30 | ????????for (int i = 0; i < n; i++) color[i] = NIL;
      |         ^~~
a.cc:30:9: error: expected ':' before 'for'
   30 | ????????for (int i = 0; i < n; i++) color[i] = NIL;
      |         ^~~
      |         :
a.cc:30:9: error: expected primary-expression before 'for'
   30 | ????????for (int i = 0; i < n; i++) color[i] = NIL;
      |         ^~~
a.cc:30:9: error: expected ':' before 'for'
   30 | ????????for (int i = 0; i < n; i++) color[i] = NIL;
      |         ^~~
      |         :
a.cc:30:9: error: expected primary-expression before 'for'
   30 | ????????for (int i = 0; i < n; i++) color[i] = NIL;
      |         ^~~
a.cc:30:9: error: expected ':' before 'for'
   30 | ????????for (int i = 0; i < n; i++) color[i] = NIL;
      |         ^~~
      |         :
a.cc:30:9: error: expected primary-expression before 'for'
   30 | ????????for (int i = 0; i < n; i++) color[i] = NIL;
      |         ^~~
a.cc:30:9: error: expected ':' before 'for'
   30 | ????????for (int i = 0; i < n; i++) color[i] = NIL;
      |         ^~~
      |         :
a.cc:30:9: error: expected primary-expression before 'for'
   30 | ????????for (int i = 0; i < n; i++) color[i] = NIL;
      |         ^~~
a.cc:30:9: error: expected ':' before 'for'
   30 | ????????for (int i = 0; i < n; i++) color[i] = NIL;
      |         ^~~
      |         :
a.cc:30:9: error: expected primary-expression before 'for'
   30 | ????????for (int i = 0; i < n; i++) color[i] = NIL;
      |         ^~~
a.cc:30:9: error: expected ':' before 'for'
   30 | ????????for (int i = 0; i < n; i++) color[i] = NIL;
      |         ^~~
      |         :
a.cc:30:9: error: expected primary-expression before 'for'
   30 | ????????for (int i = 0; i < n; i++) color[i] = NIL;
      |         ^~~
a.cc:30:9: error: expected ':' before 'for'
   30 | ????????for (int i = 0; i < n; i++) color[i] = NIL;
      |         ^~~
      |         :
a.cc:30:9: error: expected primary-expression before 'for'
   30 | ????????for (int i = 0; i < n; i++) color[i] = NIL;
      |         ^~~
a.cc:30:9: error: expected ':' before 'for'
   30 | ????????for (int i = 0; i < n; i++) color[i] = NIL;
      |         ^~~
      |         :
a.cc:30:9: error: expected primary-expression before 'for'
   30 | ????????for (int i = 0; i < n; i++) color[i] = NIL;
      |         ^~~
a.cc:30:25: error: 'i' was not declared in this scope
   30 | ????????for (int i = 0; i < n; i++) color[i] = NIL;
      |                         ^
a.cc:31:1: error: expected primary-expression before '?' token
   31 | ????????for (int u = 0; u < n; u++){
      | ^
a.cc:31:2: error: expected primary-expression before '?' token
   31 | ????????for (int u = 0; u < n; u++){
      |  ^
a.cc:31:3: error: expected primary-expression before '?' token
   31 | ????????for (int u = 0; u < n; u++){
      |   ^
a.cc:31:4: error: expected primary-expression before '?' token
   31 | ????????for (int u = 0; u < n; u++){
      |    ^
a.cc:31:5: error: expected primary-expression before '?' token
   31 | ????????for (int u = 0; u < n; u++){
      |     ^
a.cc:31:6: error: expected primary-expression before '?' token
   31 | ????????for (int u = 0; u < n; u++){
      |      ^
a.cc:31:7: error: expected primary-expression before '?' token
   31 | ????????for (int u = 0; u < n; u++){
      |       ^
a.cc:31:8: error: expected primary-expression before '?' token
   31 | ????????for (int u = 0; u < n; u++){
      |        ^
a.cc:31:9: error: expected primary-expression before 'for'
   31 | ????????for (int u = 0; u < n; u++){
      |         ^~~
a.cc:31:9: error: expected ':' before 'for'
   31 | ????????for (int u = 0; u < n; u++){
      |         ^~~
      |         :
a.cc:31:9: error: expected primary-expression before 'for'
   31 | ????????for (int u = 0; u < n; u++){
      |         ^~~
a.cc:31:9: error: expected ':' before 'for'
   31 | ????????for (int u = 0; u < n; u++){
      |         ^~~
      |         :
a.cc:31:9: error: expected primary-expression before 'for'
   31 | ????????for (int u = 0; u < n; u++){
      |         ^~~
a.cc:31:9: error: expected ':' before 'for'
   31 | ????????for (int u = 0; u < n; u++){
      |         ^~~
      |         :
a.cc:31:9: error: expected primary-expression before 'for'
   31 | ????????for (int u = 0; u < n; u++){
      |         ^~~
a.cc:31:9: error: expected ':' before 'for'
   31 | ????????for (int u = 0; u < n; u++){
      |         ^~~
      |         :
a.cc:31:9: error: expected primary-expression before 'for'
   31 | ????????for (int u = 0; u < n; u++){
      |         ^~~
a.cc:31:9: error: expected ':' before 'for'
   31 | ????????for (int u = 0; u < n; u++){
      |         ^~~
      |         :
a.cc:31:9: error: expected primary-expression before 'for'
   31 | ????????for (int u = 0; u < n; u++){
      |         ^~~
a.cc:31:9: error: expected ':' before 'for'
   31 | ????????for (int u = 0; u < n; u++){
      |         ^~~
      |         :
a.cc:31:9: error: expected primary-expression before 'for'
   31 | ????????for (int u = 0; u < n; u++){
      |         ^~~
a.cc:31:9: error: expected ':' before 'for'
   31 | ????????for (int u = 0; u < n; u++){
      |         ^~~
      |         :
a.cc:31:9: error: expected primary-expression before 'for'
   31 | ????????for (int u = 0; u < n; u++){
      |         ^~~
a.cc:31:9: error: expected ':' before 'for'
   31 | ????????for (int u = 0; u < n; u++){
      |         ^~~
      |         :
a.cc:31:9: error: expected primary-expression before 'for'
   31 | ????????for (int u = 0; u < n; u++){
      |         ^~~
a.cc:31:25: error: 'u' was not declared in this scope
   31 | ????????for (int u = 0; u < n; u++){
      |                         ^
a.cc: At global scope:
a.cc:35:1: error: expected unqualified-id before '?' token
   35 | ??
      | ^