Solution
Not hard, But need consider carefully. Still can be kind of game problem.
Let define the concepts below:
Top of mountain,Bottom of mountain。Top of mountain means the point $i$ which $p_i > p_{i\pm{1}}$. Bottom of mountain means the $i$ which $p_i<p_{i\pm{1}}$.Left/Right side of mountain. Left/Right the side between two nearbytop of mountainandbottom of mountain.Length of side. Of course the length of the side of mountain. The length of side can apply for left side and right side.
conclusion:
Let's say the maximal value of Length of side is max.
If and only if there is only one top of mountain $i$, both the lenght of left side of $i$ and the lenght of right side of $i$ are max and the max is odd. Then this $i$ is the only solution.
Otherwise, just print 0.
Prove case by case:
- If Qingshan not choose the
top of mountainwhichlengthis notmax. Then Dainel only need start from thebottom of mountainwhichlengthismax. - If there are no less than two side's
lengthis max, and the these two side is not for the sametop/bottom of mountain. Then whatever Qingshan choose (of course one oftop of mountain), Daniel only need choose another one. So no possible two win. Just print 0. - If the two side which
lengthismaxis two side for abottom of mountain. Then Daniel only need choosethe bottom of mountain. Then Qingshan will lose. Just print 0. - If only one
sidewhichlengthismax. Then Dainel only need choose the point in the side. Which distance between that point andthe top of mountainis even, and this distance longer thanlength of another side. Then Qingshang will always lose. Because if Qingshan go to Daniel side, because it's even, it will lose. If Qingshan go to another side, then thelengthis lesser than Daniel. So just print 0. - If both
sideoftop of mountainismax. But themaxis even. Then of cours, Qingshan will chose thetopand Dainel will chose thebottom. If Qingshan go with Dainel side, then because of even, Qingshan will lose. If Qingshan go with another side, then because of same length, Qingshan will lose. Just print 0. - If not all the case above. the case is the
length of both side of topis same, and thislenghtismax, and thismaxis odd. Then Qingshan chose thetop, Daniel chosebottomcan win. Print 1.
Code
Submission #109888377 - Codeforces
Codeforces. Programming competitions and contests, programming community

Forgot case #5 when I was solving this problem at beginning. Got WA answer before I realized that.
