We will hold AtCoder Beginner Contest 439.
- Contest URL: https://atcoder.jp/contests/abc439
- Start Time: http://www.timeanddate.com/worldclock/fixedtime.html?iso=20260103T2100&p1=248
- Duration: 100 minutes
- Writer: physics0523, Nyaan, kyopro_friends, blackyuki
- Tester: MMNMM, yuto1115
- Rated range: ~ 1999
- The point values: 100-200-300-425-450-525-650
We are looking forward to your participation!








Hi, that will be my first contest. Anyway, good luck everyone.
Good luck.
Thanks awa.
Good luck to you!This is my third contest.
This is also my first contest.Good luck to you!
Wow,I know you at luogu,are you in kindergarten?
Thank you
good luck
I'm too!!!
Good luck for you!
hahaha!
?
What did you mean?
I have this question too
what did you mean?Please answer my question.
Good luck!
Gave the contest. It was good. When and where can I find the editorial for this contest ?
Here
What a big difficult gap between F and G.
I solved 5 problems. Got confused on problem E for a long time...
is E sweep line ?
My solotion is not.
Can you give some hints ?
Consider sorting the segments and turn it into a LIS question.
thanks
Yes.I mean it.
Happy New Year! And it's a great contest as a gift for 2026, because A~F are very easy and G is challenging for advanced contestants.
Great contest! I solved 5 problems.(A — E)
got 3 WAs on B because I forgot that YES is not Yes ;((
I really have to start getting more used to early morning programming...
I got 2 WAs. Created new atcoder snippet separetly.
E was such a pain, I recognised LIS — knew had to handle consecutive same elements somehow.
I only tried with sorting in increasing a and then increasing b.
Editorial shows answer breaking ties by decreasing b?
I did the exact same thing, and couldn't find a counter case
In case anyone got 5 wa in E (Kite) like me, consider following testcase: 5 1 1 2 2 3 1 3 2 3 3 expected ans: 3 and not 2.
If we have an array $$$P_0, P_1, P_2, \dots, P_N$$$, how to compute $$$\sum_{t=1}^{N}(1 - P_t)^{i - 1} \cdot P_t \cdot (1 - P_{t - 1})^{L - i}$$$ for each $$$i$$$ from $$$1$$$ to $$$L$$$ fast?
Change the loops. Instead of looping over $$$t$$$ (The number of turns) by fixing the $$$i$$$-th player, fix the turn and loop over $$$i$$$. Then it turns into a geometric series.
I want the value of that summation for each $$$i$$$ separately not the sum of it over all $$$i$$$.
Sorry I wasn't clear enough. It turns into a geometric series and we can use a generating function to solve it.
Group the terms depending on $$$i$$$ as $$$B_t$$$ and the terms independent of it as $$$A_t$$$. Now the loop is $$$\sum_{t=1}^N A_tB_t^i$$$. Now make a polynomial $$$\sum_{t=1}^N A_t(B_tx)^i$$$ by summing for each $$$i$$$. The closed form of this polynomial is $$$\sum_{t=1}^N \frac{A_t}{1-B_tx}$$$. This is a sum of rational polynomials that can be added by DnC. The answer for person $$$i$$$ is the coeffecient of $$$x^i$$$.
(Btw for G, in this sum we actually don't want $$$(1-P_t)^{i-1}$$$ which means (presumably) the probability that the first $$$i-1$$$ people didn't win in the $$$t$$$-th turn. We actually want the probability that the first $$$i-1$$$ people didn't win in ANY OF the first $$$1,2,\cdots t$$$ turns. Similar in the term for the last $$$L-i$$$ people. So we need to use the prefix sum of the probabilities in these two parts)
Original problem for E:https://www.luogu.com.cn/problem/P2782
This is what G made me think:
That's very vivid.
why getting wrong answer on 3rd
You need to check whether a number n has exactly one pair. For example, 8^2 + 1^2 = 65 and 7^2 + 4^2 = 65, 65 has two pairs, and therefore it should not be counted.
but why this fails like u have
x^2 + y^2 = nso instead of checking for x and y fixxand putx+1thenx+2till not exceedingnnow here x can go at mask root n and y can also go max root n so
rootn * rootnwhich is n andn =1e7?then why like i am not gettingTLEi am gettingwrong answerroot(1e7) = 3000+... so total num of operations like 1e6+... it can easily pass. for wa, you need to check each number appear exactly 1 times , otherwise not count. this might help you:link
I solved E but my solution was surprisingly complex for E. Segment tree + input compression + sweep. I read that some people solved it with LIS. Do you mean actually reducing the problem to LIS or did you implemented a similar solution to LIS but maintaining best sequences for 2 types. Those that ends on a segment directed in bottom-right and those directed to top-right?
If you reorder pairs by A increasing, then getting LIS on B's gives you some valid non-intersecting subset and it is easy to show that this is the solution if all A's are different.
Now, if A's collide, you can break the tie by B's decreasing. Now you can't take two elements of same A so LIS is still the answer.
and the general LIS algo is what you need
Thank you @Kikos
When A's collide, can't we only use the minimum B for such elements. Because anyways, we can only take one element from all these with same A, and choosing the minimum is the best since LIS also does only that. But, this gives wrong answer on some test case. I don't know why. Have been stuck on it for a while. Would appreciate some help
a = [1, 2, 2, 2, 3] b = [2, 1, 3, 5, 4]
You can't take neither min or max element with a=2, if you want it to fit nicely into 1-2-3 sequence
Oh, got it! So dumb on my part. Thanks though
gl & hf!