Блог пользователя vego2000im

Автор vego2000im, история, 4 года назад, По-английски

problem: Link On Spoj

Code: My Code

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

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

»
4 года назад, # |
  Проголосовать: нравится +14 Проголосовать: не нравится

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.