Beautiful vertices


whats wrong in the code

hello @samardeep

      p[y]=x;
      c[x]++;
	c[y]=0;

why u r making c[y] =0 ?, it will clear out all the counts of children of y.

also

   for(auto i:p){
        int child=i.first;
        int parent=i.second;
        if(c[child]>c[parent]){
            ans++;
        }
    }

here u will count same vertex more than once , becuase 1 single vertex can be parent to more than one vertex.

so instead of iterating through parent , iterate through all the vertex and then decide wheter to count this array of not