We will hold Denso Create Programming Contest 2025(AtCoder Beginner Contest 413).
- Contest URL: https://atcoder.jp/contests/abc413
- Start Time: http://www.timeanddate.com/worldclock/fixedtime.html?iso=20250705T2100&p1=248
- Duration: 100 minutes
- Writer: MMNMM, MtSaka, sounansya, toam, PCTprobability
- Tester: yuto1115, physics0523
- Rated range: ~ 1999
- The point values: 100-200-300-425-450-525-575
We are looking forward to your participation!








When we are trying to submit a solution, there is no way to submit. Why?? And why the task is not readable? when we click in any problem, no descriptions is opened? Is it a bug or it could be a problem in my system?
emm
The Problem G is exactly the same as the problem CodeChef Starters 121 / CHEFESCAPE. I used a silly BFS search when I solved it nearly 1.5 year ago, and this time I use a better and easier DSU to implement it.
Solution 1.5 year ago: here
Solution today: here
Problem $$$D$$$ is so annoying to implement.
How did you do it? I exhausted all GP properties I knew but couldn't get to the answer
EDIT: Found out I was not checking for r=+-1. A possibly good contest that was ruined.
Let
rbe the common ratio wherer = a[i] / a[i - 1]Property of GP:
a[i] * a[i] = a[i - 1] * a[i + 1].If all elements are positive or negative,
r > 0so sort and check the property.Tricky case is when you have both positives and negatives. In that case definitely
r < 0you have to alternate between positive and negative elements starting with positive or negative element whichever you have more of, but if you have equal no of positive and negatives you need to check both starting elements (positive and negative) and see if the property is satisfied in any of them.All you have to do is sort by absolute value. That will cover the case of $$$r \lt 0$$$.
sort based on absolute values and check b^2 = a*c
can you share your code of sort based on abs
Don't forget about the edge cases like
[2,-2,2,-2]wherer = -1Submission Linkthis test case failed my bad
For D, I tried to first separate the sequence into negative and positive part, then sort positives normally and sort negatives in reverse, then intersect them to restore the geometric sequence.
what could be the issue in the logic?
can't I just avoid floating point precision lost using big decimal?
For sequences like $$$[1,1,1,-1,-1,-1]$$$ this doesn't work since the order can be random, and could lead to $$$2$$$ different value of $$$r$$$.
True, but I did handle this edge case, whenever the number of positive and negative equal, I do two passes and check for both of them. i.e. [1, -1, 1, -1, 1, -1] and [-1, 1, -1, 1, -1, 1]
what about $$$[1,1,1,-1,-1]$$$ ?
then the count of positive and negative are not equal, I will consider the only possibility which is [1, -1, 1, -1, 1].
or if the input is [-1, -1, -1, 1, 1], then I only consider this [-1, 1, -1, 1, -1]
anyway, now I see what is the intended solution with GP property
just sort the elements based on their absolute values and check for GP properties. Also, don't use float or double division, use long and check b^2 = a*c property of GP
I tried that, it didn't work. Submission
You missed the edge cases like [2,-2,2,-2] etc. before sorting just check for this condition — absolute values of all the elements are same and difference between positive and negative elements is
<=1Yeah, that's so annoying
Can anyone explain me in D, why abs(neg-pos)<=1 condition is there? [2,2,2,2,2]is also a gp right? here abs(pos-neg)>1
see for the cases abs(neg-pos) > 1 we must check the property a[i]*a[i] == a[i-1]*a[i+1]. (array is sorted based on absolute values)
For the cases like [-2,-2,2,2] , [2,-2,-2,2,-2] , [2,-2,-2,-2] sorting based on absolute won't work but there are possible rearrangements.
[2,-2,2-2] and [-2,2,-2,2,-2] are possible. No possible rearrangement for third case as abs(neg-pos)>1.
Thanks for your amazing F, I really enjoy it
G too easy than other rounds' G. D too rubbish than other rounds' D.
Trash C.
F**KING AtCoder put a problem with ORIGIN IN PREVIOUS ABCs
Today's C
The origin
The exactly same code(modification is because of the different input format) can pass both problems.
Thank you for problems D and E, I submitted G, 3 mins late.
How did you do D ? Can you please share your code also
The idea is to sort by magnitude, and store ratio (a[i+1] / a[i] in simple fraction) in a set. If size is 1, then it's GP. The only edge case is when the ratio is 1 or -1, handle that separately.
https://atcoder.jp/contests/abc413/submissions/67324535
How did you solve $$$E$$$?
iterating from (1LL<<0) to (1LL<<(n-1)) then for every valid index j if ( a[j] > a[j+(1LL<<i)] ) then swap the element of position j && j+(1LL<<i) of length (1LL<<i)
https://atcoder.jp/contests/abc413/submissions/67346748
it can be solved using recursion too,, approach would be similar like merge sort
G is too easy for an ABC's G.
I took so long on D to find out that I forgot to check for r = +-1. Lost 20 mins to that and thus didn't have enough time to give to F. Oh well.
Problem G is basically a simple version of LC 3235.
Or this one
But it has one more funny step.
My stupid solution to problem F.
Main fact. Choose a cell. Look at answers for neighbouring cells. The first player will block the minimum one, so the second player will choose the second minimum one.
But we can't do it with a usual bfs, as the dependency is cyclic.
Idea 1. Process cells in increasing order of answer (like in Dijkstra). When the cell has at least two calculated neighbours, set the answer for it and insert it into set. This is fast and wrong, since we can miss the neighbour with less answer, which will be calculated later.
Idea 2. Do "for for" and calculate the answer for all cells as in idea 1. Do it again and again, until it stops change. This is correct and slow.
Idea 3. Do "Idea 1" ++ "Idea 2". This is AC.
Can anyone help me with what's wrong with this submission for problem : D submission Logic : 1) If the array contains only positive or only negative elements then just sort the array and check for GP. 2) If there are both positive and negative elements then again sort it , but this time look where to start the GP , for example consider the first positive element and first negative element , and u can decide based off whose magnitude is greater , then alternatively we can check for if its a GP as have done in the code.
Surprisingly , I got 29 WAs , wasnt expecting the logic to be soo wrong ...
What happens when n=2?
Can anyone please help me in debugging my solution for problem D.
1)I sorted the array based on abs(value).
2)After that a general G.P check
3)And then if there is a mix of negative and positive elements then I tried checking if all the three elements are either +,-,+ or -,+,- .
Still I am getting only 3AC
https://atcoder.jp/contests/abc413/submissions/67371107
check for r = +1, -1.
https://atcoder.jp/contests/abc413/submissions/67375374
Facing a similar issue getting 3ACs , can you give a suggestion?