# Can't wait for the editorials of ADAROOKS2 and BINARY

**URL:** <https://discuss.codechef.com/t/cant-wait-for-the-editorials-of-adarooks2-and-binary/25460>\
**Category:** editorial\
**Tags:** editorial\
**Created:** [May 13, 2019, 8:49am UTC](https://discuss.codechef.com/t/cant-wait-for-the-editorials-of-adarooks2-and-binary/25460 "2019-05-13T08:49:48Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![sapjv](https://discuss.codechef.com/user_avatar/discuss.codechef.com/sapjv/32/3653_2.png) [@sapjv](https://discuss.codechef.com/u/sapjv)\
**Post date:** [May 13, 2019, 10:18am UTC](https://discuss.codechef.com/t/cant-wait-for-the-editorials-of-adarooks2-and-binary/25460/21 "2019-05-13T10:18:47Z")

</div>

Thanks @shivamchef

I will also explore and learn from it.

---

<div class="post-metadata">

**Author:** ![shubh17cs](https://discuss.codechef.com/user_avatar/discuss.codechef.com/shubh17cs/32/299083_2.png) [@shubh17cs](https://discuss.codechef.com/u/shubh17cs)\
**Post date:** [May 13, 2019, 10:18am UTC](https://discuss.codechef.com/t/cant-wait-for-the-editorials-of-adarooks2-and-binary/25460/22 "2019-05-13T10:18:49Z")

</div>

It seems not, It is the error i also faced the same and then corrected it.

---

<div class="post-metadata">

**Author:** ![shivamchef](https://discuss.codechef.com/user_avatar/discuss.codechef.com/shivamchef/32/5634_2.png) [@shivamchef](https://discuss.codechef.com/u/shivamchef)\
**Post date:** [May 13, 2019, 10:20am UTC](https://discuss.codechef.com/t/cant-wait-for-the-editorials-of-adarooks2-and-binary/25460/23 "2019-05-13T10:20:03Z")

</div>

ur welcome 🙂 .

---

<div class="post-metadata">

**Author:** ![sapjv](https://discuss.codechef.com/user_avatar/discuss.codechef.com/sapjv/32/3653_2.png) [@sapjv](https://discuss.codechef.com/u/sapjv)\
**Post date:** [May 13, 2019, 10:24am UTC](https://discuss.codechef.com/t/cant-wait-for-the-editorials-of-adarooks2-and-binary/25460/24 "2019-05-13T10:24:54Z")

</div>

I spended almost 3-4 days in trying to solve this problem and i also caught all your mentioned observations except this " we will create road between two points whose Distance between parallel lines is minimum".

Thanks @vasco_lorde for clarifying the problem.

---

<div class="post-metadata">

**Author:** ![potatio](https://discuss.codechef.com/user_avatar/discuss.codechef.com/potatio/32/2326_2.png) [@potatio](https://discuss.codechef.com/u/potatio)\
**Post date:** [May 13, 2019, 10:51am UTC](https://discuss.codechef.com/t/cant-wait-for-the-editorials-of-adarooks2-and-binary/25460/25 "2019-05-13T10:51:00Z")

</div>

For ADAROOKS, I managed to place \Theta(N \log N) rooks - on row i, place rooks on columns i + 2^k - 1 where k starts from 1 (all 1-based indexes) untill you reach the end of the board. It is not too hard to show that no rectangles will be formed this way. The first row has \log\_2(N) rooks, and you can show the asymptotic behavior claimed.  
The actual number of rooks will eventually be greater than 8N, because of the asymptotics.

However, for N = 100, the above gives around 500 rooks only. You need to find certain diagonals in the bottom quadrant (currently empty) along which you can place rooks to reach 800. This made it tricky, but I got an AC this way.

---

<div class="post-metadata">

**Author:** ![shubh17cs](https://discuss.codechef.com/user_avatar/discuss.codechef.com/shubh17cs/32/299083_2.png) [@shubh17cs](https://discuss.codechef.com/u/shubh17cs)\
**Post date:** [May 13, 2019, 10:53am UTC](https://discuss.codechef.com/t/cant-wait-for-the-editorials-of-adarooks2-and-binary/25460/26 "2019-05-13T10:53:17Z")

</div>

oh i cant beilive this i was so close . 😣

---

<div class="post-metadata">

**Author:** ![potatio](https://discuss.codechef.com/user_avatar/discuss.codechef.com/potatio/32/2326_2.png) [@potatio](https://discuss.codechef.com/u/potatio)\
**Post date:** [May 13, 2019, 10:55am UTC](https://discuss.codechef.com/t/cant-wait-for-the-editorials-of-adarooks2-and-binary/25460/27 "2019-05-13T10:55:55Z")

</div>

TREEDEG too was quite hard. I got the generating function for all trees on n vertices, but then, the actual answer you need requires evaluating some n^{th} mixed derivative at some n-dimensional point. Will be very interesting to see if someone actually solved it this way, I feel like DP was the actual way to go here.

---

<div class="post-metadata">

**Author:** ![schleppel](https://discuss.codechef.com/user_avatar/discuss.codechef.com/schleppel/32/24644_2.png) [@schleppel](https://discuss.codechef.com/u/schleppel)\
**Post date:** [May 13, 2019, 11:12am UTC](https://discuss.codechef.com/t/cant-wait-for-the-editorials-of-adarooks2-and-binary/25460/28 "2019-05-13T11:12:31Z")

</div>

ADAROOKS2 basically breaks down to “find a row of rooks where no two pairs of rooks have the same distance from each other”.

Then print this line n times where each line is shifted by a different offset and padded by dots to get the correct width.

One valid solution is where each line is shifted by its own line number:  
O…O…O…O.OO…O…O…O…O…  
.O…O…O…O.OO…O…O…O…O.  
…O…O…O…O.OO…O…O…O…O

(ideally start with offset +48 or so and just add one for each line)

edit: the forum won’t let me post too many dots and the output is fcked up.  
it looks like this: [screenshot](https://imgur.com/a/WHuF84c)

---

<div class="post-metadata">

**Author:** ![vivek\_1998299](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@vivek\_1998299](https://discuss.codechef.com/u/vivek_1998299)\
**Post date:** [May 13, 2019, 11:14am UTC](https://discuss.codechef.com/t/cant-wait-for-the-editorials-of-adarooks2-and-binary/25460/29 "2019-05-13T11:14:53Z")

</div>

Hi, I dont know if it helps, but see if you can understand my approach(I dont think I have explained that well),

[https://pastebin.com/raw/EX76ZX2g](https://pastebin.com/raw/EX76ZX2g)

---

<div class="post-metadata">

**Author:** ![potatio](https://discuss.codechef.com/user_avatar/discuss.codechef.com/potatio/32/2326_2.png) [@potatio](https://discuss.codechef.com/u/potatio)\
**Post date:** [May 13, 2019, 11:35am UTC](https://discuss.codechef.com/t/cant-wait-for-the-editorials-of-adarooks2-and-binary/25460/30 "2019-05-13T11:35:15Z")

</div>

Thank you! I was looking at a different generating function:

f(x\_1, \ldots, x\_n) = (x\_1 + \ldots + x\_n)^{n - 2} = \sum\_Tx\_1^{d\_1 - 1} \ldots x\_n^{d\_n - 1}

which is harder to manipulate. Your approach is great!

---

<div class="post-metadata">

**Author:** ![frax](https://discuss.codechef.com/user_avatar/discuss.codechef.com/frax/32/26627_2.png) [@frax](https://discuss.codechef.com/u/frax)\
**Post date:** [May 13, 2019, 11:42am UTC](https://discuss.codechef.com/t/cant-wait-for-the-editorials-of-adarooks2-and-binary/25460/31 "2019-05-13T11:42:06Z")

</div>

In the problem WTBTR I was pretty confused about multiplying by sqrt(2). My approach was correct until it was multiplied by sqrt(2). Can anyone describe his idea of this problem to me?

---

<div class="post-metadata">

**Author:** ![shubh17cs](https://discuss.codechef.com/user_avatar/discuss.codechef.com/shubh17cs/32/299083_2.png) [@shubh17cs](https://discuss.codechef.com/u/shubh17cs)\
**Post date:** [May 13, 2019, 12:04pm UTC](https://discuss.codechef.com/t/cant-wait-for-the-editorials-of-adarooks2-and-binary/25460/32 "2019-05-13T12:04:17Z")

</div>

You don’t have to multiply your answer with sqrt(2). According to the formula of minimum distance of line from a point, the denominator will always be sqrt(2) .

> distance of a line x1+y1+c from a point (x,y) is given by  
> d = Ax+By+c/ sqrt(A^2+b^2)  
> Since A and B are both 1or -1 so the denominator will always be sqrta(2)

---

<div class="post-metadata">

**Author:** ![frax](https://discuss.codechef.com/user_avatar/discuss.codechef.com/frax/32/26627_2.png) [@frax](https://discuss.codechef.com/u/frax)\
**Post date:** [May 13, 2019, 12:14pm UTC](https://discuss.codechef.com/t/cant-wait-for-the-editorials-of-adarooks2-and-binary/25460/33 "2019-05-13T12:14:15Z")

</div>

☹ I missed this… I calculated this exactly. But I didn’t consider that a^2+b^2 is going to be always sqrt(2). 😄 LOL.

---

<div class="post-metadata">

**Author:** ![keima915](https://discuss.codechef.com/user_avatar/discuss.codechef.com/keima915/32/2253_2.png) [@keima915](https://discuss.codechef.com/u/keima915)\
**Post date:** [May 13, 2019, 12:26pm UTC](https://discuss.codechef.com/t/cant-wait-for-the-editorials-of-adarooks2-and-binary/25460/35 "2019-05-13T12:26:16Z")

</div>

For ADAROKS2, you can use idea similar to this [A005282 - OEIS](https://oeis.org/A005282)

---

<div class="post-metadata">

**Author:** ![shubh17cs](https://discuss.codechef.com/user_avatar/discuss.codechef.com/shubh17cs/32/299083_2.png) [@shubh17cs](https://discuss.codechef.com/u/shubh17cs)\
**Post date:** [May 13, 2019, 12:26pm UTC](https://discuss.codechef.com/t/cant-wait-for-the-editorials-of-adarooks2-and-binary/25460/36 "2019-05-13T12:26:43Z")

</div>

You missed a big deal 😄

---

<div class="post-metadata">

**Author:** ![shubh17cs](https://discuss.codechef.com/user_avatar/discuss.codechef.com/shubh17cs/32/299083_2.png) [@shubh17cs](https://discuss.codechef.com/u/shubh17cs)\
**Post date:** [May 13, 2019, 12:28pm UTC](https://discuss.codechef.com/t/cant-wait-for-the-editorials-of-adarooks2-and-binary/25460/37 "2019-05-13T12:28:43Z")

</div>

Thank you for this ❤

---

<div class="post-metadata">

**Author:** ![shubh17cs](https://discuss.codechef.com/user_avatar/discuss.codechef.com/shubh17cs/32/299083_2.png) [@shubh17cs](https://discuss.codechef.com/u/shubh17cs)\
**Post date:** [May 13, 2019, 12:30pm UTC](https://discuss.codechef.com/t/cant-wait-for-the-editorials-of-adarooks2-and-binary/25460/38 "2019-05-13T12:30:11Z")

</div>

you left these two then which one u solved???

---

<div class="post-metadata">

**Author:** ![potatio](https://discuss.codechef.com/user_avatar/discuss.codechef.com/potatio/32/2326_2.png) [@potatio](https://discuss.codechef.com/u/potatio)\
**Post date:** [May 13, 2019, 12:37pm UTC](https://discuss.codechef.com/t/cant-wait-for-the-editorials-of-adarooks2-and-binary/25460/40 "2019-05-13T12:37:54Z")

</div>

Rotate the points so that you don’t have to worry about the square roots at all.

---

<div class="post-metadata">

**Author:** ![mm\_311269\_mm](https://discuss.codechef.com/user_avatar/discuss.codechef.com/mm_311269_mm/32/21_2.png) [@mm\_311269\_mm](https://discuss.codechef.com/u/mm_311269_mm)\
**Post date:** [May 13, 2019, 12:42pm UTC](https://discuss.codechef.com/t/cant-wait-for-the-editorials-of-adarooks2-and-binary/25460/41 "2019-05-13T12:42:16Z")

</div>

Really nice approach. That part where you generated the required expression using expansion of e^x was really a new thing to learn ! 🙂

---

<div class="post-metadata">

**Author:** ![nuttela](https://discuss.codechef.com/user_avatar/discuss.codechef.com/nuttela/32/271972_2.png) [@nuttela](https://discuss.codechef.com/u/nuttela)\
**Post date:** [May 13, 2019, 12:51pm UTC](https://discuss.codechef.com/t/cant-wait-for-the-editorials-of-adarooks2-and-binary/25460/42 "2019-05-13T12:51:31Z")

</div>

ADAROOKS2 is easy, if you find the pattern 🙂

[Previous page](https://discuss.codechef.com/t/cant-wait-for-the-editorials-of-adarooks2-and-binary/25460.md?page=1)

[Next page](https://discuss.codechef.com/t/cant-wait-for-the-editorials-of-adarooks2-and-binary/25460.md?page=3)
