All about problems in Volume 5. If there is a thread about your problem, please use it. If not, create one with its number in the subject.
Moderator: Board moderators
- Experienced poster
- Posts: 128
- Joined: Tue Nov 29, 2011 8:40 am
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=]
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:
Notice that there is also one space too many between "tree(s)" and "and".
- New poster
- Posts: 15
- Joined: Wed Jul 23, 2014 12:57 am
Thank you very much. I got it accepted now.
- New poster
- Posts: 4
- Joined: Thu Jan 01, 2015 2:51 pm
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.