題目來源:https://sci.me.ntnu.edu.tw/Contest/ContestAnnounList
題目如下
感謝chatgpt將筆者C++程式碼轉換成Python,請參考c126-acm-536-TreeRecovery