We will hold AtCoder Beginner Contest 387.
- Contest URL: https://atcoder.jp/contests/abc387
- Start Time: http://www.timeanddate.com/worldclock/fixedtime.html?iso=20250104T2100&p1=248
- Duration: 100 minutes
- Writer: Nyaan, yuto1115
- Tester: MtSaka, sounansya
- Rated range: ~ 1999
- The point values: 100-150-350-400-500-550-675
We are looking forward to your participation!








Wow! Looking forward to solve 5 problems.
Okay I hate C , gutted
I am Chinese.
I love the cuteness of the first 3 problems in ABC contests how submissive and obedient they are, I love the feelings of domination.
I sloved 2 problems.a&b
a and b were very easy. but c ? i could not find any technique.
There is a general approach to deal with this kind of problems called digit dp.
E is so hard, even harder than F
In my opinion, the order of the problems isn't quite right. $$$D$$$ and $$$F$$$ are classic problems, while $$$C$$$ and $$$E$$$ require more thinking. The results show that fewer contestants solved $$$C$$$ than $$$D$$$, and fewer solved $$$E$$$ than $$$F$$$. The difference is almost double.
People needs to think but they don't like thinking so you must push them to think, now a lot of contestants got a change to actually exercise problem-solving by struggling with problem C.
Atcoder needs to use more testers!
That's how I thought during this contest:
why there are so many 2025?
why 2025 is in every problem?
why 2025 is so special?
wait
ac-predictor tells that I could get a new rating of 2025?
2025 is so magical!
ok pro
which extension you are using to predict the ratings on Atcoder?
avalible on GreasyFork.
very educational contest for me. learned that pow doesnt give good precision + dijkstra is god damn slow.
I solved every problem except C today LOL
What is the intended solution of C? And any hint for E please?
ans = count of snake numbers in [10, R] — count of snake numbers in [10, L — 1]
Submission
I meant how to find answer in [10, R]. I solved it using digit DP, is there an easier way of solving it?
brute force for all possible no. of digits
For E, try to think about the divisibility properties of two consecutive numbers. I tried first 10 and 11, 9 and 10 and so on... The good thing I figure out is that if you find some number with sum of digits 8 and divisible by 8, then the next number will have sum of digits 9 and be divisible by 9.
Brute force below n = 10^5.
Consider divisibility rules under 10. Which ones are nice to work with?
Numbers with sum of digits 1,3,9 are always good, due to the rules for 3 and 9 considering the sum of digits.
Try a sum of 2 for the first number and 3 for the second, or 8 for the first and 9 for the second. See if you can construct values that cover an entire order of magnitude (e.g. values from 1500-15000), such that you use 4 or less digits for the lower bound.
Extend your values from Hint 4 to any arbitrary length number.
now i need to learn about functional graph, it has been haunting me in every contest
Didn't like C and E :(
Forgot to MOD the ans in F ,realised after contest ended :(
For problem G, the composition of formal power series is not needed.
The editorial calculated $$$F\circ G$$$ where $$$F=\sum_{i\leq 0}\frac{x^in^{i-2}}{i!}$$$. Distribute the $$$n^{i-2}$$$ factor into $$$G$$$, i.e., replace $$$G$$$ with $$$\frac{G}{n}$$$, and the problem becomes calculating the exponent of the formal power series.
May I ask what editorial are you referring to? I don't see any mention of $$$n^{i-2}$$$ in this editorial:
https://atcoder.jp/contests/abc387/editorial/11875
ok, I assume it is this one: https://atcoder.jp/contests/abc387/editorial/11873
(and I also assume $$$i \gt 0$$$, not $$$i\le 0$$$)
why is this failing for problem D: code ?
i cant seem to figure out whats wrong here
The minimum distance travelled to reach a node need not be the same from both directions (as explained in the diagram).
It is also possible that a node is reachable only from 1 direction.
So it is possible, for a node $$$(i, j)$$$, that the distance to $$$(i, j)$$$ is less when reached after a horizontal step, but the destination can only be reachable when $$$(i, j)$$$ is reached after a vertical step.
thank you so much! i cant believe i missed this.
Problem C was really cool! Took a lot of time but felt very satisfied after solving it.
After I got stuck in C for 50 minutes:
Me while doing A-B : I can solve every problem in the world!!
Me at C : I think this is not the right world..
E is just testcases , D is garbage implementation ,score distribution is random,this contest sucks.
Personally surprised everyone found E hard; I personally found E to be surprisingly easy when considering that you can extend values by inserting 0 in the middle of the number and then working with "easy" divisibility rules that don't care about that (1,2,3,4,5,6,8,9, but especially 2,3 and 8,9 since they're consecutive and 1 and 5 can immediately be shown to be impossible to manipulate this way under the constraints, though pairing 3 and 4 can work as an alternate construction, specifically by extending (111,112) to (1011,1012), (10011, 10012), etc.).
For problem E, I solved it case by case, by using one of the following patterns:
starting with 11, 80, 62, 53, 35, 26, 17, while ending with all zeros. A really impressive constructive problem!
please tell me why I got wrong on D, I had wasted a lot of time and I am upset
I am confused about why I got wrong…… help me plz
You should consider if it is the same when arriving at a point from left/right and up/down.
I had considered it, but I cant construct a sample to prove that my code is wrong.....
You just considered it cannot move as the same direction.But you should split every point into two points,which represent the last step is left/right or up/down.Because they are different but your code regards it as the same.
I'm sorry I didn't quite get editorial of E. So they just throw some constructions, then there are some dots implying that there are some more constructions? And why there won't be other twin numbers?
Yeah I think the listed pairs in hint 4 may not be enough to cover all cases, so you may need to write a few more. There are other twin numbers, we are just trying to create a rule to generate one pair of twin numbers for any sufficiently large N,
Check this solution: https://atcoder.jp/contests/abc387/submissions/61387781 Only one construction is sufficient if num > 10^7.
Again, why?
Could someone please take a look at my solution for F? I believe it is O(NM) but it suspiciously TLE on 3 test cases. Link
My approach is quite straightforward (functional graph, cycle detection, dp with prefix sums) and is essentially the same as that of the official solution.
bump
Stuck with C for 40 min. Maybe AtCoder should swap E and F?
Can anyone please tell me what is wrong with my implementation of problem C, my approach is almost same as given in editorial. submission