6

Codeforces Round #809 Editorial

 2 years ago
source link: http://codeforces.com/blog/entry/105008
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Some stats about the round

Pre-contest predictions
Who did what?

Solutions

Problem A

Solution
Code

Problem B

Solution
Code

Problem C

Solution
Code

Problem D1

Solution
Code

Problem D2

Solution
Code

Problem E

Solution
Code

27 minutes ago, # |

super speedy editorial, BucketPotato orzzzzzz

25 minutes ago, # |

Nice ProblemSet :)

20 minutes ago, # |

Fast editorial.. Why D2 has an unusual memory limit?

  • 19 minutes ago, # ^ |

    To make the problem harder

  • 17 minutes ago, # ^ |

    (copy-pasted from here)

    There is a two-pointers memory solution in D2 that we wanted to cut off. We decided it would be fine since all of the correct memory solutions (from testers, authors, and the coordinator, including in Python and Java) use less than 1/6 of that memory.

    • 3 minutes ago, # ^ |

      And this two-pointer method can be optimized to linear memory by getting the sqrt(ai) distinct values online(one by one).

      That is, instead of preprocess all the sqrt(n) values, we get only a current value for ai and get the next value one by one during the process of two-pointer, which costs linear memory since one ai have only one current value.

      • 1 minute ago, # ^ |

        You're right. Unfortunately none of the setters or testers came up with this idea :(

19 minutes ago, # |

I enjoyed the round! In particular, want to share a sol for E that involves kruskal tree (reachability tree/line tree). So lets say for each , you gave the 'th edge wegiht . Then you can find the MST (min spanning tree) of the graph. Define as the maximum value of any weight on the path from to on the MST. The answer will end up being the max value of for all .

When it comes to reachability/max path weight on an MST, we can use a kruskal tree. In particular, the answer will be the weight of on the kruskal tree. A cool property of lca is that . So this means we can build a segment tree over all the nodes. Some node on the segtree stores the lca of all the nodes in the kruskal tree. The merge function in this segtree will be finding the lca.

The final complexity is since you have to call lca times per query.

  • 3 minutes ago, # ^ |

    If you use query lca methods (such as euler tour + sparse table) and use another sparse table to query lca of a range, you can achieve time per query.

18 minutes ago, # |

Good contest. The difficulty of Problem A is very appropriate, and Problem B and C are very interesting. D1 and D2 are also good. Thank you.

Spoiler

17 minutes ago, # |

My submission for B that doesn't use DP: 164767537.

  • a moment ago, # ^ |

    I had the same solution: 164776738

16 minutes ago, # |

C was absolute delight...i was think of applying DP but it was just common sense

14 minutes ago, # |

For D2, https://codeforces.com/contest/1706/submission/164790931 logically maintains only n elements in the 'hold' vector, yet MLE's. Any clue if this is because CF counts total memory allocated throughout the execution of the program, or am I actually using more space than I think?

  • 10 minutes ago, # ^ |

    You don't release the memory from hold[start-1]. The memory is still reserved, it doesn't get released just because the vector became empty. You can use hold[start-1].shrink_to_fit() at the end, or swap it with an empty vector to release it.

13 minutes ago, # |

c in the even case just checked left and right leaning cool building's should have checked all possibilities.. this is the closest i've ever been to solving div 2 C. hope i'll solve c in next div2 rounds

13 minutes ago, # |

Posting a comment to edit it when problem ratings arrive, so I can say how right/wrong I was

7 minutes ago, # |

Great contest though!

3 minutes ago, # |

Problem B was quite standard ! It took lots of time to understand the problem first rather than solving it


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK