## Editorial for DMOPC '17 Contest 5 P4 - Intersecting Arcs

Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.

Submitting an official solution before solving the problem yourself is a bannable offence.

Author: r3mark

There is no intended solution for the first subtask.

For the second subtask, let be the number of ways to draw the arcs in the first dots so that the number of open arcs (only the left endpoint has been drawn so far) is and there have been exactly intersections where intersections between a completed arc and an open arc are counted as well. For each there are three choices for the dot. The first case is not putting any endpoint on this dot. This contributes ways. The second case is putting a left endpoint on this dot, which increases the number of open arcs by one and doesn't change the number of intersections. This contributes ways. The final case is putting a right endpoint on this dot. This decreases the number of open arcs by one. Note that there are possible left endpoints which this right endpoint can connect to, and depending on which endpoint is chosen, can increase the number of intersections by . So this case contributes . The final answer is .

Time Complexity: For the final subtask, we optimize the solution for the second subtask. Note that each row only depends on so the dp table can be compressed to . Also, for the third case where the dot is used as a left endpoint, we can optimize this by computing the prefix sum of in and using this to handle the third case in instead of as previously done. The prefix sums only need to be computed for each and , so that gives .

Time Complexity: • commented on March 31, 2018, 1:20 p.m.

If the first 10 points have three intersections formed by arcs (1, 7), (4, 8), and (6,10), and there are three open arcs at points 2, 3, and 9, this pattern should contribute to dp.

When a moves to the 11th point, one of the states we need to calculate is dp. According to the editorial, the above example should contribute to dp if the 11th point is an end point of an arc. However, in this case no matter which open arc is connected to the 11th point, an additional intersection is formed which transits to dp. I do not see how the example can transit to dp.

Can anybody explain where I misinterpreted the editorial?

• commented on March 31, 2018, 5:51 p.m. edited

In the editorial's solution (which is the only one I'm aware exists), the intersections are counted when the left arc in the intersection is completed and only the left endpoint of the right arc has been chosen. So the intersection you are asking about has already been counted earlier.

Edit: I've updated the editorial - the previous definition of what was being stored by dp was incorrect.
{"ft_lang_label":"__label__en","ft_lang_prob":0.9371562,"math_prob":0.95541245,"size":2642,"snap":"2020-45-2020-50","text_gpt3_token_len":591,"char_repetition_ratio":0.13078089,"word_repetition_ratio":0.014957265,"special_character_ratio":0.2316427,"punctuation_ratio":0.09774436,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9867569,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48],"im_url_duplicate_count":[null,1,null,null,null,null,null,null,null,6,null,1,null,1,null,1,null,5,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,2,null,null,null,null,null,null,null,null,null,2,null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-10-25T23:11:39Z\",\"WARC-Record-ID\":\"<urn:uuid:96233365-aa48-49d2-9147-750b100bc3e1>\",\"Content-Length\":\"22836\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:8a5e20f6-a45d-4749-b80e-806ced6082a7>\",\"WARC-Concurrent-To\":\"<urn:uuid:20bf1a8c-2a27-4afc-87c4-6e33f6c64b74>\",\"WARC-IP-Address\":\"104.27.158.145\",\"WARC-Target-URI\":\"https://dmoj.ca/problem/dmopc17c5p4/editorial\",\"WARC-Payload-Digest\":\"sha1:FHMTIE4QGAWKJ4AGEFBTTJW3EYLTS5I2\",\"WARC-Block-Digest\":\"sha1:TX5O6IBOLFCSKDTH6O3WFQEJEIDK4MCH\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-45/CC-MAIN-2020-45_segments_1603107890028.58_warc_CC-MAIN-20201025212948-20201026002948-00710.warc.gz\"}"}