We will hold AtCoder Beginner Contest 412.
- Contest URL: https://atcoder.jp/contests/abc412
- Start Time: http://www.timeanddate.com/worldclock/fixedtime.html?iso=20250628T2100&p1=248
- Duration: 100 minutes
- Writer: Nyaan, cn449
- Tester: toam, sounansya
- Rated range: ~ 1999
- The point values: 100-200-300-425-500-525-650
We are looking forward to your participation!









Why did the
Rated Rangeis0-2799some days ago but0-1999now?It was an ARC combined round (Div. 1 + Div. 2 ARC)
This is ABC
Why is the color above bule ?
Maybe because the writers love blue.
The downvoters are newbies who want it back to colour grey lol.
I wish it was green :)
Why is the colour above blue? (I don't like blue,so do anybody know how to switch it back?)
Change your monitor settings and only let the red LED light work.
I dislike it too. Think kindof odd...
why can't I participate as a rated participant?
Because you participated more than 5 minutes after the start of the competition.
F is a very good expectation question.
D is a trash idea
Good Brute force question I felt.
Segmented sieve is new for me. Pretty cool approach!!
same bro, i solved the problem on paper but didn't have a single clue abt segmented sieve
Problem D is nice. The way to solve it is so ingenious.
I've tried something similar, but got WA https://atcoder.jp/contests/abc412/submissions/67166187
Someone please help me with question C :( I tried greedy with binary search, it didn't pass 12/32 cases.
I am also greedy to solve C and submit many solutions that is WA, which make me upset now.
why binary search, I just iterated until the next element doesn't fall, keeping idx pointer. But for the edge case with n=2, I wrote 0 instead 2, that was my WA, lost 30 minutes
yea but it shouldn't matter right?? Could you check my solution with some test case??
Oh yeah, thanks for pointing that out. This is why I see no solutions which actually sort the array.
I do. link
My solution sorts the array
You could check THIS out. Might not be a very well written code, but good enough.
Thanks this is a nice one.
I am pretty sure that problem D or something very similar has already occur somewhere with much stricter constraints.
I solved it today with MCMF on a graph: s -> v of capacity 2 cost 0, (v + n) -> t capacity 2 cost 0, and u -> (v + n) capacity 1 cost (1 if there were no such edge initially and -1 otherwise). Answer == (m * 2 + mincost) / 2.
However, this approach is kinda hard to prove, because it is not necessary that if edge (u -> (v + n)) is taken to the flow, then (v -> (u + n)) is also taken. If the graph is directed, then there is no issue, problem solved. However, it also works for undirected(i mean that the answer is correct, not that the flow is built in a way that all edges are taken in pairs). But i cannot prove it. Can anyone?
What an overkill)
I solve it following way. Degree of all vertices is two, hence the graph is set of cycles. There is a bijection between such graphs and permutations (edges are $$$(i, a[i]) \; \forall i \in [1, n]$$$). Iterate on permutations. We need to just check, that there is no loop $$$i = a[i]$$$ and no multiedge $$$i = a[a[i]]$$$.
Let $$$X$$$ be the number of edges in permutation, that are given, and $$$Y$$$ be the number of edges in permutation, that are not given. Then the possible answer is $$$(m - X) + Y$$$.
orz
In problem F editorial I can't understand anything. Can someone, please, explain it more adequately?
Let $$$p_x$$$ = expecting number of sock draws if now we have sock of such a color that occurs exactly $$$x$$$ times among all socks. Since $$$x \leq 3001$$$, one of the solutions is to construct SLE on these variables and solve it.
The answer is $$$p_{t}$$$ where t = number of socks of color C among all socks.
An what are those SLEs?
Consider using "total number of socks have same color as the one on your hand" (include the one on your hand), then you would switch to another sock you draw only when that one have more number in total, so "total number of ..." would be non-decreasing in the whole process, and you can find the probability to transit from $$$u$$$ to $$$v$$$ for every $$$u \le v$$$, then let $$$E[u]$$$ be the expected number of times we need to draw to have a pair when start with a sock have $$$u$$$ in total. Then we have $$$E[u] = 1 + \sum\limits_{v \gt u} Pr[u \rightarrow v] E[v] + Pr[u \rightarrow u]E[u]$$$ so $$$E[u] = \frac{1 + \sum\limits_{v \gt u}Pr[u \rightarrow v] E[v]}{1 - Pr[u \rightarrow u]}$$$, then just dp in decreasing order of $$$u$$$.
Thank you The problem was that I couldn't understand the definition of dp state in editorial, and thought, it is "number of steps, before we first time got the $$$i$$$-th sock type".
not able to figure out what is wrong with this submission :
my solution
You just messed up a bit with total number of socks
fixed
Thanks. It’s working now. So the problem was that I didn’t count the socks that wasn't in the drawer initially.
About geminipromc: is he an AI?
D in $$$ O(n!.n log(n)) $$$ Link
I think E is very hard.I noticed that the prime solving,but I got a TLE...........Because my algorithm for factoring prime factors is not good.......
But I think D is an easy problem , It just use a DP
C is a problem to practice thinking,I got the solution in 18min。I use a Binary search and greedy to solve it.
can any one please explain how to cross the 4th problem barrier at atcoder.......
i am getting WA in C submission any testcase where it will fail
I haven't seen a problem which can search to get the full score for a long time.
I think I can say that, here we go again, for today's problem F.
:D https://mirror.codeforces.com/blog/entry/142558#comment-1272566
It seems that ABC really likes this kind of dp, which asks to find out max or min of some expectation.
appreciate any help i could get about my WA on C!
https://atcoder.jp/contests/abc412/submissions/67211725
thank you in advance!
In F, if two drawers have the same no. Of socks, the expectation should be the same, right??
also if someone can tell me what's wrong in this edit: got it I think I need to sleep
Can somebody explain me the problem E please i tried to follow the editorial but that didn't helped me . Somebody please explain in simpler terms Thankyou
For problem C,I wanna to use priorityqueue to solve ,but it doesn't work for 5 tests,and I can't find the mistakes...