Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

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

Автор shubhsy, история, 6 лет назад, По-английски

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.

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

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

You gave the wrong link to your code

»
6 лет назад, # |
Rev. 3   Проголосовать: нравится +24 Проголосовать: не нравится

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 лет назад, # ^ |
      Проголосовать: нравится -10 Проголосовать: не нравится

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

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

Here you are:

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

DFS?