vego2000im's blog

By vego2000im, history, 4 years ago, In English

problem: Link On Spoj

Code: My Code

Approach: I am using Bibartite graph and got WA and I don't know why!!

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

| Write comment?
»
4 years ago, # |
  Vote: I like it +14 Vote: I do not like it

Two errors: First, On lines 45-46, you have

for(auto i : adj)
    i.clear();

what this loop does is copy the vector to a new variable i and clear the contents of i. To modify the actual adj vector you need

for (auto &i : adj)

Second, on line 49 you initialize edges to size m + 1, but then in your for loop you push back (x, y) pairs to the end of the vector, so now you have an edge vector of length 2m + 1 and when you iterate over all the edges at the end, you always include an edge pair (0, 0) which isn't right.

Fixing those two errors gets AC.