his code is giving the correct answer: 7
2014-05-11 23:36 GMT+08:00 caethan <[email protected]>: > What answer does your code give for: > > N,M = 4, 5 > K = 10 > > The answer should be 7, by producing this map (or something similar): > .**.. > *..*. > *.*.. > .*... > > But based on your description of your code, I suspect it may be producing > a slightly less efficient map: > ..... > .***. > *...* > .***. > > On Sunday, May 11, 2014 10:14:14 AM UTC-5, edston wrote: > > w = width of grid and h = height > > if w<=2 or h<=2 we print k > > > > > > else > > Note: point here means an intersection P(x,y) > > > > > > We start from the center of the grid. > > > > The center point C(cx,cy). initially cx = w/2 and cy = h/2; > > and we mark C as counted. And we increase the "stones". variable for > counting stones. > > > > > > Then we add unmarked points on right, top, left and bottom (if exists) > of center C to a vector. > > > > and we keep increasing marked every time we add to the vector and > increase the "stones" > > > > > > To keep track that all 4 sides are covered we use a variable angle that > goes from 0 to 3. clockwise from right to bottom. once angle is 4 that > means we covered all 4 possible sides. > > > > > > > > Then we check if the current center C is on the boundary or not. if it > is not on the boundary then we decrease the stones count by one. As it has > to be an enclosed point. > > > > > > Now we select a new point as center among marked points. First > preference is a point which is not on the boundary. if we dont get such a > point then we go for the first point in the vector. > > > > > > > > Once the marked count is = K. we break the loop > > > > > > outside the loop we once again check whether the Point C is an inner > point already or not. > > > > > > Now the code works for small input but for the large input in few cases > there is a difference of only 1 when I check with respect to an accepted > solution. > > > > I have an extra 1. > > > > > > If I had done this I would have gotten through. Not sure which case is > failing. > > > > > > thanks > > > > > > > > > > > > > > On Sun, May 11, 2014 at 4:43 PM, Xiongqi ZHANG <[email protected]> > wrote: > > > > > > > > As far as I could understand, you are trying to add one stone each time > and stop whenever your marked reaches k. > > > > > > > > > > Take your case as an example, 6 116 633 > > > > > > > > > > One of the correct answer can use only 215 pieces and get 666 enclosed. > > > > > > > > > > I am not sure how you can get to this anwser if you try to add stone one > by one. > > > > > > > > 2014-05-11 22:31 GMT+08:00 Xiongqi ZHANG <[email protected]>: > > > > > > > > > > > > > > It is too difficult for me to read the code and understand your mind. > > > > > > > > > > > > At lease write some comments in your code, or give a brief decription on > what approach you are using. > > > > > > > > > > > > > > > > > > > > > > 2014-05-11 20:16 GMT+08:00 vivek dhiman <[email protected]>: > > > > > > > > > > > > > > Sure > > > > > > Here you go! > > > > > > http://ideone.com/vyzTLN > > > > > > > > > > > > > > Thanks > > > > > > > > > > > > > > On Sun, May 11, 2014 at 2:04 PM, Xiongqi ZHANG <[email protected]> > wrote: > > > > > > > > > > > > > > > > > > I have no access to pastebin. > > > > > > > > > > > > > > > > Would you mind putting it on ideone? > > > > > > > > 2014-05-11 20:00 GMT+08:00 vivek dhiman <[email protected]>: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Solved small but large isn't working > > For example for this case: 6 116 633 > > My answer is 216 but required is 215 > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Here is the code: http://pastebin.com/KAUZzEGS > > > > I am missing an edge case. Which one? > > > > > > > > > > -- > > Thanks & Regards > > > > Vivek Dhiman > > > > > > > > > > > > -- > > > > You received this message because you are subscribed to the Google > Groups "Google Code Jam" group. > > > > To unsubscribe from this group and stop receiving emails from it, send > an email to [email protected]. > > > > To post to this group, send email to [email protected]. > > > > To view this discussion on the web visit > https://groups.google.com/d/msgid/google-code/CABaJBvLPhWNfO3yXxvjRMvWixO-dTEOe1tgici8juYhs13hmyA%40mail.gmail.com > . > > > > > > > > > > > > > > For more options, visit https://groups.google.com/d/optout. > > > > > > > > > > > > > > > > > > > > -- > > > > You received this message because you are subscribed to the Google > Groups "Google Code Jam" group. > > > > To unsubscribe from this group and stop receiving emails from it, send > an email to [email protected]. > > > > To post to this group, send email to [email protected]. > > > > To view this discussion on the web visit > https://groups.google.com/d/msgid/google-code/CAGDEU-KE%2Boz46HiMqmCc_gqpZ8NAc5%3DrOkT-BLas4xZKDLOr9g%40mail.gmail.com > . > > > > > > > > > > > > > > For more options, visit https://groups.google.com/d/optout. > > > > > > > > > > > > -- > > Regards > > Vivek Dhiman > > > > > > > > > > > > > > -- > > > > You received this message because you are subscribed to the Google > Groups "Google Code Jam" group. > > > > To unsubscribe from this group and stop receiving emails from it, send > an email to [email protected]. > > > > To post to this group, send email to [email protected]. > > > > To view this discussion on the web visit > https://groups.google.com/d/msgid/google-code/CABaJBvKnahNZ6NaonpGz63AfU-KztzJ0Gt8CPMM_ahw21Ox_9g%40mail.gmail.com > . > > > > > > > > > > > > > > For more options, visit https://groups.google.com/d/optout. > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > You received this message because you are subscribed to the Google > Groups "Google Code Jam" group. > > > > To unsubscribe from this group and stop receiving emails from it, send > an email to [email protected]. > > > > To post to this group, send email to [email protected]. > > > > To view this discussion on the web visit > https://groups.google.com/d/msgid/google-code/CAGDEU-L0gdsZLq7k2NZpFy5QgtkHAjyYSsjLbtcNTRCpf6ttGA%40mail.gmail.com > . > > > > > > > > > > For more options, visit https://groups.google.com/d/optout. > > > > > > > > > > > > -- > > Regards > > Vivek Dhiman > > -- > You received this message because you are subscribed to the Google Groups > "Google Code Jam" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/google-code/eac9c0a5-59f5-413c-8f55-54ada210d2f7%40googlegroups.com > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Google Code Jam" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/CAGDEU-L37xF187vw4sJiqZ5mOj3Ws9VrUCo2ZQE9%3D7jFQ06LmA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
