TOPIC

Wrong answer (5%)

🎈Leandro Rodrigues🎈 asked 2 years ago

Alguém pode me ajudar? Estou recebendo WA 5% com esse programa. Nele verifico se todas as estações tem pelo menos uma linha de transmissão, ou seja, se existe uma rota entre qualquer par de estações. Se alguém puder me explicar o que estou fazendo de errado ou mostrar um caso de teste em que meu programa gere a saída errada eu ficaria agradecido!!

Question solved. Code removed.

This topic was solved and cannot recieve new replies.

  • feodorv replied 2 years ago

    For this problem you should check whether the graph is connected or not. You can do it by means of DSU/BFS/DFS. Meanwhile what is the output of your code on second input sample?

  • feodorv replied 2 years ago

    I can not think of an entry that does not work

    Here it is:

    6 6
    1 2
    2 3
    3 1
    4 5
    5 6
    6 4
    0 0

    .

    I still do not know how to implement a DFS

    You can find an implementation on the internet, for example https://www.quora.com/How-do-I-find-if-undirected-graph-is-connected-or-not-using-DFS

  • 🎈Leandro Rodrigues🎈 replied 2 years ago

    The program actually fails in this test case. Thanks a lot for the help!!!

  • 🎈Leandro Rodrigues🎈 replied 2 years ago

    The output generated at the second input is "falha" as expected. I still do not know how to implement a DFS or BSF, but I think this program should solve the problem, I can not think of an entry that does not work. But thank you so much for having responded! =)