We will hold Japan Registry Services (JPRS) Programming Contest 2025#2 (AtCoder Beginner Contest 415).
- Contest URL: https://atcoder.jp/contests/abc415
- Start Time: http://www.timeanddate.com/worldclock/fixedtime.html?iso=20250719T2100&p1=248
- Duration: 100 minutes
- Writer: yuto1115, physics0523
- Tester: MMNMM, math957963
- Rated range: ~ 1999
- The point values: 100-200-350-400-450-525-575
We are looking forward to your participation!








why me fifth problem wrong 4 test bag
No communications while contest
How to do C? I find it more difficult than D
same here
deduced the logic of D in like less than 5 minutes but was stuck on C for around 25 minutes but couldnt think of anything
Do a BFS solution, starting from the mask 0. To get the next masks for each mask, iterate to find each bit that are still turned off of the mask, and turn it on. If it is a safe state to reach, and also hasn't been visited, then it can be pushed to the queue.
My DP solution for problem E does not work on 4 cases. It's a modified minimum path implementation. Can someone give me a hint on those 4 cases?
can you share your code?
https://atcoder.jp/contests/abc415/submissions/67747349
You have to maximize the minimum of coins he had had on the path instead of the coins he lastly have.
So, we need to maximize the minimum, one will use what?
How to solve F? Some kind of a SegTree variation?
don't know if it is intended, but I did it this way. submission
Merging nodes, with each node having prefix, suffix and mid of the highest frequency letter and the letter
https://atcoder.jp/contests/abc415/submissions/67759806
Why is above submission TLE??
Your inner loop in binary search is quadratic on (n+m)
you should do i <= min(s, n-1) and i = max(s-(m-1), 0LL) and initial value.
However your code is still WA for another reason, I don't know.
This is the sub sub
Use a segment tree (with each node representing one substring) to collect the following information
it's kind of like CSES 1190 and CSES 3226 combined, but with strings instead of integer additions.
submission to F: here
I solve it: Code:
just to bulid a tree and do something
I did something using a lazy segtree representing an array where a[i] is the streak of consecutive same characters ending at index I, and you just query the max element with the range for the answer.
Did anyone else get AC*39 WA*1 in problem G?
I did the following: Use dp to calculate the optimal solution for N<=1000. I guessed you could get to <=1000 with just 1 index. Try all M possible indices and pick the best. But WA in 1 case.
The only difference is you need to do dp in <= 300 * 301
Wow. I also didn't make the observation that there are at most 300 useful indices.
I have 38 ACs and 2 WAs
I sorted the exchange methods by $$$\frac{A}{B}$$$ from small to big, and then use each method in order, and use one as much as possible (until it can't be used) and then move on. I don't know why WA in 2 cases
Same as me, I tried to find the cycle and were very pleased when 39/40 passed and it is still grey, and the last case just turn yellow. Kill me !
Yes, N <= 1000 -> N <= 100000 with observation that we have <= 300 useful pairs and it passed
I think when you violently DP, you should sort the items by the value of the $$$a_i$$$ from largest to smallest to ensure that the order in which you choose items is optimal.
I write a (max, +) matrix pow in G and don't find $$$V^3\log{n}$$$ has already exceed $$$10^9$$$.
F solution code looks unnecessarily complicated. Here's mine. Also, I get that ABCs are meant to be standard but this F was just bad cuz it's very standard + you could use integers and nothing would change.
How to do D?I tried three ways to sort the array,but none of them is right.
Sort the array by $$$A_i - B_i$$$; If some $$$A_i - B_i$$$ are equal, sort them by $$$A_i$$$, from small to large.
Any idea why this logic fails ?
This is very close to the solution-You just need to sort by $$$A_i$$$ in ascending order in case of $$$A_i - B_i$$$ is same!
https://atcoder.jp/contests/abc415/submissions/67748782
why i got 44*AC 2*WA on problem E?
and i dont think there's something wrong
You have to maximize the minimum of coins he had had on the path instead of the coins he lastly have.
So, we need to maximize the minimum, one will use what?
but the official editorial didn't use binary search either, why does its logic work then
It's actually reversing the dp order so one can decide the next step
But binary search is actually more obvious
I solved G in last 6 minutes and I reached 1 Dan!!! E and G are interesting.
In problem G, I try to find the minimum "cycle", which means dp[i] = dp[i-cycle] + constant hold for every i when i is large. However, I got 39 AC and 1 WA on the last test case. How large cycle can be given the problem constraint ?
For Question D Any idea why this logic fails ?
your code fails this following test case:
Correct output: 11, your code's output (incorrect): 0
I think the reason why it fails is due to the incorrect calculation of the number of times the operation will be applied and the value of variable
ctafter applying a number of operations.Here is my in-contest submission: https://atcoder.jp/contests/abc415/submissions/67755510
Did anyone know what test case "04_handmade_04.txt" in problem G is ? Very curious.
This test cuts solutions where N (size of dp array) is too small
In F , can't we simply make segtree with hash of 26 letters?
i have tried this but it is giving TLE and MLE both
i just don't understand if making segment tree for each character and simply doing maximum subarray sum in a range is not allowed then why the Time Limit of question is 4 sec
It should be allowed, but i don't know why not.
i have seen many solutions submitted by different user but not able to find a single solution passing all the testcases using this approach
if you find any kindly tell me too
Sure i will tell you.
I actually got AC using that approach: https://atcoder.jp/contests/abc415/submissions/67789991
faizanhussain2310 Here is correct code.
Thank you Lilinta for sharing
Can someone help me understand the solution to D?
I think today's ABC is really good for education. From problem C to F, the topics are [bitmask+bfs], [greedy+math], [binary search+dp] and [data structure(segment tree)].
Can you explain D?
Yes, of course. It is my pleasure if I could help little.
Here are some important observations for solving this problem.
Suppose that there are two strategies to reach the following two states. State1, we have already got y stickers and currently have n-x1 empty bottles left. State2, we have already got y stickers and currently have n-x2 empty bottles left. if n — x1 <= n — x2, it is always better to choose the second strategy, otherwise we choose the first one. In a word, if we could get y stickers, it is better to lose as few empty bottles as possible. This has already inspired us that greedy algorithm might work, so we are going to have a try.
For some pair (a,b), it in fact implies that we would lose a-b empty bottles in order to get one sticker (as long as we have at least a empty bottles now). So, according to observation 1, we should choose the pair (a,b) which has the minimal value of a-b. If there are two pairs (a1,b1) and (a2,b2) which satisfy a1-b1=a2-b2, we should choose the one with smaller a1. For instance, assume that we have 6 empty bottles now, and there are (a=7, b=6) and (a=3,b=2). Of course we should choose (a=3,b=2).
Now the solution is somehow straightforward. We sort all the pairs (a,b), first by a-b in an increasing order, and if there are multiple pairs which have the same value of a-b, we should then sort them by the vaule of a in an increasing order (we could also delete those which have larger value of a). Finally, we start from the first pair until the last one, and try to get as many stickers as possible for the current pair.
https://atcoder.jp/contests/abc415/submissions/67767974 can somone debug the code
Sort $$$A_i - B_i$$$ in descending order instead of ascending
Also, please carefully check the code for calculating the times you can exchange
intuition for doing such kind of sorting ?
The more cola bolltes are, the better the situation is.