# Help with acm-icpc problem

I solved this problem a few hours ago by following the “editorial” and using recursive parser, sorting and binary search Here is the link which contains a solution to the problem: https://www.comp.nus.edu.sg/~acmicpc/rcdreport-preliminarycontest.pdf (go to the “Animal Classification problem part”).

I don’t understand a particular analysis in the solution. In the link, the editorialist explains that two subtrees from two different trees share exactly the same set of leaves if their set of leaves have the same sum, minimum, maximum and number of leaves (size). Of course, this is limited to the context of the problem which describes the both trees to have leaf labels 1 to N with no repeating labels.

I made a counterexample as it didn’t seem too hard to make.

``````8
(((1,8),(6,4)),((2,3),(7,5)))
(((1,8),(7,3)),((2,4),(6,5)))
``````

The subtrees ((1,8),(6,4)) and ((1,8),(7,3)) have the same sum (i.e. 19), minimum (i.e. 1), maximum (i.e. 8), and number of leaves (i.e. 4). But they clearly do not have the same set of leaves.

Can anyone explain this?
{"ft_lang_label":"__label__en","ft_lang_prob":0.9066434,"math_prob":0.968403,"size":1100,"snap":"2020-34-2020-40","text_gpt3_token_len":295,"char_repetition_ratio":0.12773722,"word_repetition_ratio":0.0,"special_character_ratio":0.29090908,"punctuation_ratio":0.20992367,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9964428,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-09-26T01:21:39Z\",\"WARC-Record-ID\":\"<urn:uuid:6ed8ae9e-e59a-4d28-b496-ce5793aee077>\",\"Content-Length\":\"12884\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:1b580e44-8b93-49f1-b865-671ce761a940>\",\"WARC-Concurrent-To\":\"<urn:uuid:afefb885-849d-4fac-bef9-642aaeb69fc0>\",\"WARC-IP-Address\":\"18.213.158.143\",\"WARC-Target-URI\":\"https://discuss.codechef.com/t/help-with-acm-icpc-problem/12148\",\"WARC-Payload-Digest\":\"sha1:DRW6YFMND3QHWLPSL4OB3WC32F5MBP7M\",\"WARC-Block-Digest\":\"sha1:7JQI2D7SBFF6SQSQWZBNAQU6HA7WFQMN\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-40/CC-MAIN-2020-40_segments_1600400232211.54_warc_CC-MAIN-20200926004805-20200926034805-00583.warc.gz\"}"}