Please read the new rule regarding the restriction on the use of AI tools. ×

shubhsy's blog

By shubhsy, history, 6 years ago, In English

I am trying to solve a problem, "Kefa and Park", https://codeforces.me/problemset/problem/580/C Here is the code I wrote and it does not give right answer for test case 12. Please, help me out. https://codeforces.me/contest/580/submission/47677278

My code builds a tree as per the question. After I build the tree, I do perform DFS. I have a stack in which I first put the first element (Root). Now, for every iteration for as long as there is an element in the stack, I check if its parent has a non zero value of number of cats in the path and if it has, I add the number of cats at that node to the upper number and if it does not, then, I switch it to the number of cats at that node. Now, if I reach the leaf and the number of consecutive cats in that path is less than or equal to the required number, I increase the number of valid paths by one.

  • Vote: I like it
  • -21
  • Vote: I do not like it

| Write comment?
»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

You gave the wrong link to your code

»
6 years ago, # |
Rev. 3   Vote: I like it +24 Vote: I do not like it

LoOoOOOoooOooOooOooOLoOoOooOOOLOoOoOoOoOLOoooOooooOoL.

Can you not just throw the code at ppl and ask for help? Explain what your code does. Make it easy for people to help you.

I think CF badly needs ppl to screw posts such as this so that ppl can learn to write better blogs.

  • »
    »
    6 years ago, # ^ |
      Vote: I like it -10 Vote: I do not like it

    Unrateds can change their rank to something else but rateds can't change their ranks to unrated?? Mike, fix it.

»
6 years ago, # |
  Vote: I like it +71 Vote: I do not like it

Here you are:

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

DFS?