The answer provided for the question shows wrong answer

My issue

This problem is broken

My code

#include <bits/stdc++.h>
using namespace std;

int main() {
    // 'n' is our number of nodes
    int n;
    vector<int> graph[n];
    // There are no elements currently in any list
    // Given below is our input edges array
    vector<vector<int>> edges = {{0,1},{0,2},{1,3},{1,4},{2,5}};
    for(int i=0 ; i<edges.size() ; i++){
        int a = edges[i][0];
        int b = edges[i][1];
        // Here 'a' and 'b' denote that there is an edge from a to b. Thus, we can also call 'a' as parent and 'b' as child
    for(int i=0 ; i<n ; i++){
        cout<<i<<" ";
        for(int j=0 ; j<graph[i].size() ; j++){
            cout<<graph[i][j]<<" ";
    return 0;

Learning course: Trees and Binary trees
Problem Link: Implementation - Adjacency List Practice Problem in Trees and Binary trees - CodeChef

Thanks for reporting, fixed it.