Блог пользователя Ahnaf.Shahriar.Asif

Автор Ahnaf.Shahriar.Asif, история, 7 лет назад, По-английски

I have tried a lot to solve the "milking cow" problem of USACO . But WA in test 7 . I don't know what is the problem , i have tried multiple approaches , but it still wrong in test 7 . can you please help me to find my bug please ????

my code : https://paste.ubuntu.com/25901070/

problem source : http://train.usaco.org/usacoprob2?a=pxSIvVnwAXn&S=milk2

please please please help me guys , I have tried my best .

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

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

Auto comment: topic has been updated by Ahnaf.Shahriar.Asif (previous revision, new revision, compare).

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

Why are you calling it "serious help"?

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

Well, to help you, I had to solve all of my unsolved problem before this problem to access the problem page you specified.

Ok, I saw your code. You made some mistake in your code. Your code for non_milking is correct.

But in the for loop started at line no 42 you made some mistakes.

1) On line 43, you wrote: int mxx = ara[i-1].end,mnn = ara[i-1].start; initializing mxx and mnn as i-1th value is wrong. You should put this line before the for loop on line and initialize as value of index 0: int mxx = ara[0].end,mnn = ara[0].start;

2) The nested for loop is unnecessary also you made two mistake here: if(ara[i].start > ara[i-1].end)break; is wrong since you are keep tracking the max right index in mxx, you should compare the current end with mxx,

Also, you incremented i in both of the for loop. After being incremented in the nested for loop, it is again being incremented in the first for loop.

I had modified your code a bit and it got ACCEPTED. Here is the accepted code: code

  • »
    »
    7 лет назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

    Thanks a lot brother , I am from Bangladesh , a junior beginner coder (NHSPC contestant) . I have learned a lot from you , I will be grateful to you (i think you are a ICPC contestant ) . I have attended in the last NHSPC camp , I think you were there (may be not , i am not clear )