Language: C++

#include <stdio.h>
#include <stdint.h>
#include <iostream>
#include <fstream>
#include <cassert>
#include <climits>

#include <vector>
using namespace std;

#define DEBUG (0)

#if DEBUG
#define DPRINTF(...) do { \
    printf("D(L%d) %s: ", __LINE__, __func__); \
    printf(__VA_ARGS__); \
  } while (false)
#else
#define DPRINTF(...)
#endif // DEBUG

int g_time = 1;

class Vertex {
public:
  Vertex() :
    id_(-1),
    discover_time_(-1),
    finish_time_(-1),
    adjacentNum_(0),
    adjacentIds_(nullptr),
    isVisited_(false) { }

  ~Vertex() {
  }

  void setAdjacency(const vector<int> &adjacentIds);

  inline void setId(int id) { id_ = id; }
  inline void setDiscoverTime(int time) { discover_time_ = time; }
  inline void setFinishTime(int time) { finish_time_ = time; }
  inline void setVisited(bool visited) { isVisited_ = visited; }

  inline int getId() { return id_; }
  inline int getDiscoverTime() { return discover_time_; }
  inline int getFinishTime() { return finish_time_; }
  inline bool getVisited() { return isVisited_; }
  inline int getAdjacentNum() { return adjacentNum_; }
  inline int getAdjacentId(int idx) { return adjacentIds_[idx]; }

  void printTime();
  void printAdj();

private:
  int id_;
  int discover_time_;
  int finish_time_;

  int adjacentNum_;
  unique_ptr<int[]> adjacentIds_;

  bool isVisited_;
};


void Vertex::setAdjacency(const vector<int> &adjacentIds)
{
  if (adjacentIds_) assert(1);

  adjacentNum_ = adjacentIds.size();
  adjacentIds_ = unique_ptr<int[]>(new int[adjacentNum_]);

  for (int i = 0; i < adjacentNum_; i++)
  {
    adjacentIds_[i] = adjacentIds[i];
  }

}

void Vertex::printTime()
{
  printf("%d %d %d\n", id_, discover_time_, finish_time_);
}

void Vertex::printAdj()
{
  DPRINTF("%d %d", id_, adjacentNum_);
  for (int i = 0; i < adjacentNum_; i++) {
    printf(" %d", adjacentIds_[i]);
  }
  cout << endl;
}


void dfs(Vertex vertices[], int idx)
{

  DPRINTF("time %d  idx %d\n", g_time, idx);

  Vertex &vtx = vertices[idx];

  if (!vtx.getVisited())
  {
    vtx.setDiscoverTime(g_time);
    g_time++;
  }

  for (int i = 0; i < vtx.getAdjacentNum(); i++)
  {
    int id = vtx.getAdjacentId(i);
    dfs(vertices, id);
  }

  if (!vtx.getVisited())
  {
    vtx.setFinishTime(g_time);
    vtx.setVisited(true);
    g_time++;
  }

}


int main()
{
  int n;

  cin >> n; cin.ignore();
  DPRINTF("Node num %d\n", n);

  Vertex vertices[n+1];

  for (int i = 1; i <= n; i++)
  {
    int id;
    int num;

    cin >> id >> num;
    vertices[i].setId(id);
    DPRINTF("node %d (num %d)\n", id, num);

    vector<int> adjs;

    for (int j = 0; j < num; j++)
    {
      int adj;
      cin >> adj;

      adjs.push_back(adj);
    }

    if (adjs.size())
      vertices[i].setAdjacency(adjs);

    cin.ignore();
  }

#if DEBUG
  for (int i = 1; i <= n; i++) vertices[i].printAdj();
#endif

  for (int i = 1; i <= n; i++)
    if (!vertices[i].getVisited())
      dfs(vertices, i);

  for (int i = 1; i <= n; i++) vertices[i].printTime();

  return 0;
}


Compiler output:
a.cc:60:3: error: 'unique_ptr' does not name a type
   60 |   unique_ptr<int[]> adjacentIds_;
      |   ^~~~~~~~~~
a.cc: In constructor 'Vertex::Vertex()':
a.cc:31:5: error: class 'Vertex' does not have any field named 'adjacentIds_'
   31 |     adjacentIds_(nullptr),
      |     ^~~~~~~~~~~~
a.cc: In member function 'int Vertex::getAdjacentId(int)':
a.cc:49:46: error: 'adjacentIds_' was not declared in this scope; did you mean 'adjacentNum_'?
   49 |   inline int getAdjacentId(int idx) { return adjacentIds_[idx]; }
      |                                              ^~~~~~~~~~~~
      |                                              adjacentNum_
a.cc: In member function 'void Vertex::setAdjacency(const std::vector<int>&)':
a.cc:68:7: error: 'adjacentIds_' was not declared in this scope; did you mean 'adjacentIds'?
   68 |   if (adjacentIds_) assert(1);
      |       ^~~~~~~~~~~~
      |       adjacentIds
a.cc:71:3: error: 'adjacentIds_' was not declared in this scope; did you mean 'adjacentIds'?
   71 |   adjacentIds_ = unique_ptr<int[]>(new int[adjacentNum_]);
      |   ^~~~~~~~~~~~
      |   adjacentIds
a.cc:71:18: error: 'unique_ptr' was not declared in this scope
   71 |   adjacentIds_ = unique_ptr<int[]>(new int[adjacentNum_]);
      |                  ^~~~~~~~~~
a.cc:9:1: note: 'std::unique_ptr' is defined in header '<memory>'; this is probably fixable by adding '#include <memory>'
    8 | #include <vector>
  +++ |+#include <memory>
    9 | using namespace std;
a.cc:71:29: error: expected primary-expression before 'int'
   71 |   adjacentIds_ = unique_ptr<int[]>(new int[adjacentNum_]);
      |                             ^~~
a.cc: In member function 'void Vertex::printAdj()':
a.cc:89:19: error: 'adjacentIds_' was not declared in this scope; did you mean 'adjacentNum_'?
   89 |     printf(" %d", adjacentIds_[i]);
      |                   ^~~~~~~~~~~~
      |                   adjacentNum_