Page 2 of 2

Re: 599-The forest for the trees

Posted: Mon Jul 28, 2014 9:58 pm
by lbv
apcastelein wrote:I'm having an issue with my code. It works for the sample input but I get RE when submitting
Try configuring your compiler to show you all possible warnings, as that may help you catch subtle bugs. For example, when I compiled your code, I received:

Code: Select all

p.cpp: In function ‘int main()’:
p.cpp:64:17: warning: format ‘%s’ expects a matching ‘char*’ argument [-Wformat=]
       scanf("%s");
                 ^
If you want to skip that string in scanf (not store it anywhere), you may use the assignment-suppression character (see scanf's documentation for details). For example:

Code: Select all

       scanf("%*s");
Notice that there is also one space too many between "tree(s)" and "and".

Re: 599-The forest for the trees

Posted: Tue Jul 29, 2014 7:03 pm
by apcastelein
Thank you very much. I got it accepted now.

Re: 599 - The Forrest for the Trees

Posted: Fri Jan 09, 2015 5:26 am
by uohzxela
Just got AC for the problem.

Turns out you don't need to implement cycle-finding for your DFS (DFS with cycle-finding will give WA). Just a simple DFS with coloring will do; a tree will contain colored nodes. Any white node in adjacency list with an empty list is an acorn. Be sure to add edge twice because the graph is undirected.

Re: 599 - The Forrest for the Trees

Posted: Tue Apr 21, 2015 11:54 am
by uDebug
Added some input to help with testing / debugging here:

http://www.udebug.com/UVa/599