PARTHO_DAS's blog

By PARTHO_DAS, 3 years ago, In English

Hi there,

After getting Accepted to Timofey and a tree problem with DSU. I found that my solution was wrong.

My approach: In DSU I kept a vertex X in Group D if vertex X has the same color as parents of group D and there is an edge between X and some vertex of group D.

Now for calculating the result. I was iterating over every vertex. In every iteration, I visited over his adjacent vertices and kept count of their group size. After vising, if the count is equal to n — 1 then I say this is my answer and return.

If I could not get any answer then I say there is no answer.

The Main Problem: In the iteration of every vertex. I count for the same group many times for different adjaecnt vertex. So, if the counter becomes n — 1 and found an answer that an error.

This is my Wrong Accepted solution 121082526

The Hack Case:

10
1 5
1 2
3 6
3 9
3 4
4 5
6 7
7 8
9 10
2 2 1 1 2 1 2 2 1 2

For this data, The output should be NO. But My output is

YES
3

But here is another 121055514 solution which giving output NO.

So, here are two different solutions giving different outputs for the same valid input.

MikeMirzayanov Could you please check this.

  • Vote: I like it
  • +4
  • Vote: I do not like it