• + 0 comments

    Guys, write a custom main function. The one given have some issues. as pointed out in earlier answer, the loop to read in guesses has a logical error. Personally this didn't fix my problem much so I simply wrote a new main function and it works.

    In c++,

    int main()
    {
        int t;cin>>t;
        for(int i=0; i<t; i++){
            int n;cin>>n;
            vector<vector<int>> edges(n-1);
            for(int j=0, p, q;j<n-1;j++){
                cin >>p >> q;
                edges[j].push_back(p);
                edges[j].push_back(q);
            }
            int g,k;
            cin >>g>>k;
            vector<vector<int>> guesses(g);
            for(int j=0,p,q; j<g; j++){    
                cin >>p>>q;
                guesses[j].push_back(p);
                guesses[j].push_back(q);            
            }
            cout << storyOfATree(n, edges, k, guesses) << endl;
        }
    }
    

    Iam starting to hate this website. This took a lot of my time!!