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

Автор SYury, история, 6 лет назад, перевод, По-русски

1059A - Cashier

Разбор
Код

1059B - Forgery

Разбор
Код

1059C - Sequence Transformation

Разбор
Код

1059D - Nature Reserve

Разбор
Код

1059E - Split the Tree

Разбор
Код (первое решение)
Код (второе решение)
Разбор задач Codeforces Round 514 (Div. 2)
  • Проголосовать: нравится
  • +74
  • Проголосовать: не нравится

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

Fast editorial!!

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

Love you!!! Thank you posting Editorial this quick.

Still, no news of last round's editorial

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

Excellent problems! Lightening fast editorial! What more does one need!?

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

Can someone please explain D? I cannot understand the editorial.

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

    You can also ternary search the x-coordinate of the circle's center and judge the better side by calculating the minimum necessary radius. Let's assume the x-coordinate of the center be x0, then the center should be (x0,R). We enumerate all points (xi,yi) and find out the minimum radius separately for each point, which will be the R in equation like: (x0-xi)^2 + (R-yi)^2 = R^2. The maximum necessary R will be the minimum radius we need.

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

      hOW TO DO ternary search<>.Thanks in advance

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

        This is a nice explanation of ternary search. Hope it helps.

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

          I know ternary search but how to use here

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

            my analysis ternary search using by X coordinate which from common point with river.

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

            Given: River line (i.e. y=0) must be a tanget to the circle.Hence your centre point will be some (X,Y) where Y is the radius.

            1. Now find minimum Y(Use binary Search) and slide circle left to right ,to and fro (ternary search), there will be some x such that it contains all the points that satisfy for y ( if valid).

            2. Fix your x with ternary search , then find min R , for which circle (x,R) contains all points, and decide ternary search domain on basis of min value of R.
              2nd approach is efficient one.

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

For D, I did a ternary search to find the X coordinate of the center of the circle. Then calculating the radius is easy.

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

D can also be solved with a randomized algorithm much like the one used in minimum covering circle problem. The only thing to change is to make the new circle always tangent to x-axis.

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

What is wrong in this solution? Is it the precision errors for doubles in Java?

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

    Yup I guess so. Same thing happened to me in c++ as well. You can improve it by writing as

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

      Thanks!! I also tried this r2 - (y - r)2 = y2 - 2yr, where y < 107, r < 5 * 1013. So we get rid of r2 which is big. Passed Test #4, but failed on #6.

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

        you need to do sqrt(y^2 — 2yr) = sqrt(y)*sqrt(y — 2r) because y*r is also too big.

        You can also just change your binary search bound from 0...1e15 (I'm guessing you have) to 0...1e16 and it'll magically pass with your first original equation.

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

In the Code for problem 1059C - Sequence Transformation, it is sufficient to generate the required answer from n and mul only without using the global array int seq[maxn]. In particular, when n ≥ 4, the number of times mul is appended to the answer array should be exactly equal to the ceiling of n / 2, regardless of the contents of seq. The following is an Updated Code.

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

    Could you please elaborate more?

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

      It is well-known in integer numbers arithmetic that an integer sequence $$$1,2,\ldots,n$$$ has exactly $$$\lfloor \frac{n}{2} \rfloor$$$ even numbers and $$$\lceil \frac{n}{2} \rceil$$$ odd numbers. Note that the requested numbers can be written to the standard output stream on the fly without having to store it in the global array ans[].

      Spoiler

      In another comment on this problem, I wrote the following note: starting with problem size $$$n \ge 1$$$ and GCD $$$g = 1$$$,

      1. the present sequence can be expressed as $$$[g, 2g, 3g, \ldots, n g ]$$$,

      2. the answer to the three base cases when $$$n \le 3$$$ are $$$[g]$$$, $$$[g, 2g]$$$ and $$$[g, g, 3g]$$$, respectively, and

      3. the reduced recursive case when $$$n \ge 4$$$ is the same problem with problem size $$$\lfloor\frac{n}{2}\rfloor$$$ and the GCD is $$$2g$$$, where $$$g$$$ is appended $$$p = \lceil\frac{n}{2}\rceil$$$ times to the answer before solving the reduced problem, removing from the present sequence all $$$p$$$ odd multiples of $$$g$$$ that are not divisible by $$$2g$$$, typically $$$[g,3g,5g,\ldots,(2p-1) g]$$$.

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

Can anyone give more detailed explanation of B please?

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

    My solution is to check if there are exactly 8 inked cells around a cell(not empty).If so, just put a pen on a new sign.After that, compare the new sign with the given one and you can know it's YES or NO.

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

    my solution is as follow --> i have checked if cell(x,y) is '#' or not. if it is, than i have checked for all 8 adjacent direction to it that whether at least one out of 8 it is possible to make 3X3 matrix.if it is than we can fill this cell and ans is YES and it is not possible to make 3X3 matrix than NO.

    --> if cell is not '#' than continue.

    my solution is . http://codeforces.me/contest/1059/submission/43840425

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

please anyone explain,in problem c, why this algo. works?

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

    The gcd(a, a+1) is always 1. So in order to maximize lexicographically the sequence, you have to remove all the consecutive pairs. The best option to do that is to remove the odd numbers in which the gcd will be always 1. So if you have 1,2,3,4,5,...N and you remove the odd numbers you have now 2,4,6,8,... = 2(1,2,3,...floor(n/2)).

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

How can you prove that for the problem 1059C, the rest of the answer is the answer for floor(n/2) multiplied by 2?

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

    Nevermind, i just figured it out. Thanks

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

      How? Can you please tell?

      And How it is an nlog n solution? It seems to be O(n) solution

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

        The gcd(a, a+1) is always 1. So in order to maximize lexicographically the sequence, you have to remove all the consecutive pairs. The best option to do that is to remove the odd numbers. So if you have 1,2,3,4,5,...N and you remove the odd numbers you have now 2,4,6,8,10,... but that is equal to 2*(1,2,3,...floor(n/2)). From there is direct that the rest of the solution is the solution for floor(n/2) times 2

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

the running time of the code for problem C is O(n) and not O(nlogn)

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

For problem E can someone please explain the solution a lttle bit easy way. I can't understand the intuition behind the solution that why it's optimal?

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

    Consider if you are at a node in a dfs, and all the children are all already part of a chain. Obviously you can only continue one chain from one of your children, and possibly you have to start a new chain if the children's chains are too long.

    So for each of the children, just take the one that will allow you to add the most amount of nodes in the future. The reason is that for any of the children's chains, all their ancestors that could be added later are the same, so you might as well take the chain that can be extended the furthest possibly later. You can check how many ancestors you can add to a chain using binary lifting/sparse table.

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

Что может значить WA 18 в задаче B?

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

Can anyone tell the use of the statement "for(int i = 0; i < n/2; i++)seq[i] = seq[2*i + 1]/2;" in the author's code?

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

    There was no need. Just comment it out, it will work perfectly fine. seq array was just to keep the positions so that every time odd positions (from the remaining can be removed) but since it is already initialized with i+1, every time it will get alternate even odd. Just dry run for say n=10 and you will understand why it was there and why it works fine without it.

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

D solution:

  1. each point(xi,yi) requires minimum Ri where reserve is (X,0)

  2. Ri = sqrt((yi-Ri)^2+(xi-X)^2)

  3. is interpreted Ri^2 = (yi-Ri)^2+(xi-X)^2

  4. after transposition yi*Ri*2 = yi^2+(xi-X)^2

  5. thus we can find equation Ri = (yi^2 + (xi-X)^2)/(2* yi)

so , R = max( Ri = (yi^2 + (xi-X)^2)/(2*yi) )

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

    Hi, I get your point that Ri = (yi^2 + (xi-X)^2)/(2* yi). As this function is quadratic, we can find it's minima using ternary search. But actual function to minimize is R = max( Ri = (yi^2 + (xi-X)^2)/(2*yi) ). So I this case, I don't get how can we assume R is decreasing then increasing and use ternary search to find the answer. Please help, Thanks in advance!!

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

      draw graph ( X , Ri ), it can interpreted for ( X , (xi-X)^2/(2* yi)+ yi/ 2 ) if you calculated by "partial differential equation" for X , yi is constant number

      so , we can guess it is quadratic function

      we can imagine many quadratic functions in the field ,than where "max is minimum point" has special feature that there is crossed point (at max Ri)

      even near at "minimum point" increasing is larger than two crossed functions which parallel mid go to minimum point.

      also you can make skyline that looks similar quadratic function.

      so you can try ternary search for X .

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

Hello everybody. Is it possible to prove problem C? (why it works that way)

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

    As long as you have both both even and odd numbers the gcd is 1, so you need to get rid of either odd or even. It is faster to get rid of odd and get 2 as gcd (for any other number you have to get rid from all evens numbers before, which is profitable only for trivial case n=3). What happens after you delete all odd numbers? All numbers (and their gcd) are miltipliers of 2. So you can divide everything by 2 and get back 1,2,3... — same problem.

    hope it helps

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

      In other words, starting with problem size n ≥ 1 and the GCD g = 1,

      1. the present sequence can be expressed as {g, 2g, 3g, ..., ng},

      2. the answer to the three base cases when n ≤ 3 are {g}, {g, 2g} and {g, g, 3g}, respectively, and

      3. the reduced recursive case when n ≥ 4 is the same problem with problem size floor(n / 2) and the GCD is 2g, where g is appended p =  ceil(n / 2) times to the answer before solving the reduced problem, removing from the present sequence all p odd multiples of g that are not divisible by 2g, typically {g, 3g, 5g, ..., (2p - 1)g}.

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

      Thanks

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

    Intuition is this.

    Imagine if you could remove every number so gcd becomes gcd*k. Well, you have to remove all the other non divisible by k.

    Now lets compare what the result would look like if you did it:

    1111...22222...444444 111..333..99999

    But we can make the observation that it there are less numbers to remove to get gcd -> 2*gcd than other values of k. Because this takes n/2 numbers as opposed to 2n/3, 3n/4 ... which will thus be lexicographically lower.

    So it is always optimal to try to remove odd numbers when to rescursively solve.

    Edge case is 3, where the amount of odd numbers = non multiples of 3, so we take 3 instead of 2. You can look in my code if interested.

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

Hello,

Can you please explain what is the advantage of doing middle = sqrt(left * right) in case answer is greater then 1.0 in binary search? [It is code for D problem I am referring to]

Thank you!

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

For problem D,why do we init R to 1e16? Also, why is l set to 1e-16 and r to 1e16 in the can function ? I think for yi > 0, there is always a possible solution if we can set radius to infinity, am I wrong?

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

    the edge case is (x,y)=(1e7, 1),(1e7, 1e7),(-1e7, 1), (-1e7, 1e7), as far as I remember solutions is smth like 1e15/2

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

I still don't understand B QAQ Is there anyone can help me.

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

    Just put the pen into whatever possible spot you can, then check if any cell is not painted in the board we make.

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

My solution to problem C: Determine that we have write first I numbers, consider the last number, let's call it GCD. we know that next number is one of the multiple of GCD. now we know that every multiple of GCD that smaller or equal to n is in sequence now, and every multiple of any multiple of GCD is one of the multiple of GCD. and we know that for a fix number K, there is exactly floor(n/ K) multiple of K in range of 1 to n. so for every multiple of GCD (let's call it M) we calculate number of multiple of M and between those M that the number of its multiple are maximum we choose the greatest M and for floor(n / GCD) - floor(n / M) print GCD.

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

Does anyone know whats the problem with test 7 in problem E? Here is my submission. Thanks in advance! NVM solved it

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

In problem 1059B - Forgery, another O(mn) algorithm is to check all pen locations in the sub-grid 2 ≤ i ≤ n - 1 and 2 ≤ j ≤ m - 1. If none of the eight neighbors at a pen location (i, j) in this sub-grid is empty, then all these non-empty eight neighbors are painted. Finally, all cells in the grid are checked. If a non-empty cell is not painted, then the answer is "NO". Otherwise, the answer is "YES".

43922930

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

In the Solution for problem D,how do you find the upper bound for the answer .having 1e18 gave me overflow issues,but upper bound of 1e17 gave me ac. https://codeforces.me/contest/1059/submission/43925303(my code with 1e18) https://codeforces.me/contest/1059/submission/43925436(my code with 1e17)

can someone explain how to exactly find the upper bound for the value of the radius?

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

It is worth noting that in 1059E - Split the Tree you can calculate how far up vertical path that starts in current vertex can go without knowledge of binary lifting.

For every vertex calculate sum[vertex] — sum of values in all vertices on path from root to current vertex. Traverse tree recursively and maintain stack of parents for current vertex. We can use binary search over this stack to find last position where sum[current_vertex] - sum[stack[position]] exceeds sum limit in single vertical path. Difference of position and stack size will be the length of maximal vertical path that starts from our current vertex.

I've tried to come up to a linear solution for this problem but that was not successful. Can anyone provide a linear solution or prove that it is not possible?

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

    Hi, I believe I have a solution in O(n log* (n)). I just need a DSU. I sort the vertices by height (I can do it in O(n), by count sort), and greedily travel up compressing the paths. Correct me if I am wrong (please).

    Some dirty code for this: https://codeforces.me/contest/1059/submission/44409581 but I used STL sort here, so it is actually O(n log (n)), but easy to modify to get O(n log* (n)).

    Don't know if we can get linear though.

    EDIT: it's not O(n log* (n)) actually, but the time to perform O(n) operations in the DSU structure, so some inverse Ackermann function, or something.

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

      So, If I understand everything correctly, your idea is to pick naive solution (while there is at least one vertex that is not yet included into any path do following: start from the deepest such vertex and start a new path from this vertex, then expand this path upwards as long as we can) and make this observation:

      It only makes sense to check upward expansion of some path to some vertex that is not yet covered with any other path. So, instead of naively checking every vertex on our path upwards, we want to quickly skip all vertexes included into other paths and check closest not covered vertex to be included into our path.

      This check (can vertex A be included into the path that has its lowest vertex in B) can be done in O(1) with precalculated vertex depths and sums from each vertex to tree root. DSU can help us to keep groups of visited vertexes together and for every group store the highest vertex of that group to quickly find the next unvisited vertex on our path.

      Let's prove compexity. In this algorithm, we will cover all the vertexes with the paths and (in worst case) unite all sets of DSU. In details we will repeat this:

      1. Start path from deepest not covered vertex and start path upwards expansion — vertexes can be ordered by depth in O(N) using counting sort

      2. find the closest unused vertex, uniting all groups of covered vertexes together in DSU that we are skipping — O(N·α(N)) in total of all steps

      3. check if we can include found vertex into this path — O(1) for each step

      4. if we can include this vertex into our path then include it and continue expansion, otherwise finish expansion

      Steps 1 and 4 will give us exactly N vertex inclusions into groups of used each done in O(α(N)) in total.

      So we have O(N·α(N)) solution, where α(N) is inverse Ackermann function (and can be ignored in practical solutions analysis due to its extremely slow growth).

      Thanks for sharing your ideas, that is really cool improvement of a very simple solution.

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

https://codeforces.me/contest/1059/submission/43989515

what's wrong with this solution of problem C can anyone please point out ...

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

didn't get D problem's editorial

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

I have solved E with greedy and a strange binary search.

If L is  + ∞,we can use greedy:we must consider leaves first,so every node(except leaves) will join the son with minimum value if the son's value and the node's value are not exceed S,else the node's value is its number.

To ignore L,we can binary search C that every node's number will add C,then do the above greedy,if the vertical path with maximum number of nodes is not exceed L,then decrease C,else increase C.

This is my submission.However,I don't know whether I'm right.If anyone knows how to prove it or prove it is false,please reply to me,thanks:)

ps:My English is poor,if you are Chinese,you can talk with me in Chinese.My email:[email protected]

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

In problem E, the second solution's code, some of the '-' maybe make mistake and it becomes '—'. Please modify it correctly. Thank you.

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

.

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

Can someone give me ideas/methods to reduce my floating-point precision for the ternary + binary search solution?

Tried binary search — style ternary search for like 20 times, couldnt get it to work.

Still can't get it precise enough for the ternary search, and im out of ideas to optimize (already spent like 6 hours on trying random stuff lol).

https://pastebin.com/sCFbMcyV

Any ideas/suggestion will be highly appreciated

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

I am having a hard time with precision in problem D any suggestion will be appreciated 44064198

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

    Try changing (high >= low) to something like (low-high < EPS) and set the epsilon to 1e-8 or something.

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

How is something like this passing E 44173661?

Pretty sure this hits N^2 behaviour if you make a tree where you have a chain and then at the end of it it spreads out...

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

Consider the following for problem E:

Test Case Generator

Setting n = 1e5 will time out many naive greedy solutions (approx 5000ms on csa editor, cf custom invocation limits input size) such as mine

Can you please add such a case because as of right now a whole bunch of N^2 solutions are "shortest solution size" or whatever but actually shouldn't be passing the problem

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

1059E - Split the Tree: there is a simple small-to-large, $$$O(n\log{n})$$$ solution. You can read about small-to-large here.

Perform a dfs on the tree; for each node $$$s$$$, store in a set the possible nodes $$$v_1$$$ such that $$$s$$$ and $$$v_1$$$ are in the same vertical path. You can efficiently calculate the answer for each $$$s$$$ by iterating over its children and by merging the smaller set to the larger one. In the meanwhile, for each node you have to delete "impossible" paths (with sum of weights $$$> S$$$ or length $$$> L$$$): these conditions can be checked by calculating prefix sums over the vertical paths. Then, if the set of $$$s$$$ is empty, you have to start a new path from $$$s$$$ by inserting it into its set, and increase the answer by $$$1$$$. This is $$$O(n\log^2{n})$$$ (because of sets), but it's enough to pass all the tests. 95353675

To improve the complexity, you can use simple vectors instead of sets, and put an additional flag on each element of the vector ($$$1$$$ if $$$v_1$$$ is still valid, $$$0$$$ if it's invalid). Then, the condition "the set is empty" becomes "all flags are set to $$$0$$$".

UPD: I've just realized that this is $$$O(n^2)$$$ if the tree is a line with large $$$L$$$ and $$$S$$$. Even if sets are merged with small-to-large, each path can be checked up to $$$O(n)$$$ times.

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

Please explain me the error in Problem D, I have tried for a day now. My approach is doing binary search on radius.

I did binary search on radius, and to check whether such circle is possible, I take first the circle at $$$(0, r)$$$ where $$$r$$$ is mid of binary search. Now I calculate necessary shifting to align leftmost offset point into the circle left boundary. Then I check all points whether they lie inside this circle.

I am having some precision issue I think. In pretest 4 it is giving error of 0.000005, and I think it is settling for radius smaller than the optimal radius.

Please help me.

submission