Actually, this contest ended 2 months ago and you can upsolve here. But, because someone complained me about editorial of this problem yesterday and said that it was hard to understand. And also until I write this blog, just Benq and Pyqe that already submit (and both of them got AC). So, I try to rewrite a clearer explanation about this problem in this link (english version is available on page 8).
By the way, I got an idea about this problem more than 3 years ago when I was in junior high school even before I know about cp. Finally, it is published after several years of waiting.