We will hold AtCoder Regular Contest 111.
- Contest URL: https://atcoder.jp/contests/arc111
- Start Time: http://www.timeanddate.com/worldclock/fixedtime.html?iso=20210109T2100&p1=248
- Duration: 120 minutes
- Number of Tasks: 6
- Writer: yosupo sigma425
- Tester: yosupo sigma425 maroonrk
- Rated range: — 2799
The point values will be 300-400-600-600-800-1000.
We are looking forward to your participation!
For those interested, I'm planning to do a stream afterwards on Twitch.
wrong URL
Thanks, fixed.
please do on youtube
I do upload to Youtube later: my channel
Stream finished it was saying and disappeared . UPD : It was delayed by few minutes by AnandOza .
I wish good luck to all participants able to solve a problem in this contest. :/
I give up!
How to solve E?
https://codeforces.me/blog/entry/58442?#comment-422011
How does that code work? The comments don't seem to be explaining it.
EDIT: I guess this explains it, though I still don't really understand it :(
I think it can be derived from the formula: https://codeforces.me/blog/entry/65500#comment-496154.
Seems, that it's a different approach than described here.
How to solve A?
If b divides a, then we can write (a/b) % p = a%(p*b) / b . Since we have to mod the floor value, we can ignore the condition above( b|a ). I used big mod to calculate a%(p*b) My submission
how did you know (a/b) % p = a%(p*b) / b it should be p*b??
any source or explanation?
I don't know the source but it works. I found this so many days ago here.
Find modulo result of (10^N) with (M^2). The result floor divided by M is the answer.
To me, B was easier then A. How to solve A?
$$$ Answer =\frac {(10^N\%M^2 - 10^N\%M)}{M} $$$
as we know the property $$$ \lfloor \frac{\lfloor \frac{A}{B} \rfloor }{C} \rfloor = \lfloor \frac{A}{B*C} \rfloor $$$
Basically you want to calculate A
$$$A = \lfloor \frac{10^N}{M} \rfloor - \lfloor \frac{10^N}{M * M} \rfloor * M$$$
let $$$\lfloor \frac{10^N}{M} \rfloor = Q $$$ and $$$\lfloor \frac{10^N}{M*M} \rfloor = Q^\prime $$$
we know that
$$$ 10^N = Q * M + R $$$
$$$ Q = \frac {10^N - R}{M}$$$
$$$ 10^N = Q^\prime * M^2 + R^\prime $$$
$$$Q^\prime = \frac {10^N - R^\prime}{M^2}$$$
So, $$$A = Q - Q^\prime * M$$$
$$$ A = \frac{(10^N - R) - (10^N - R^\prime) }{M}$$$ $$$ = \frac{R^\prime - R} {M} $$$
$$$ =\frac {(10^N\%M^2 - 10^N\%M)}{M} $$$
Will you please explain your solution.
Imagine $$$10^n$$$ in base $$$m$$$ and you can see the answer is the second last digit.
$$$10^n = m*k + r_1$$$
$$$(10^n - r_1)/m = k$$$
$$$k = \left \lfloor \frac{10^n}{m} \right \rfloor$$$
$$$r_2 = k \mod m$$$
$$$k = m*k_2 + r_2$$$
$$$(10^n - r_1)/m = m*k_2 + r_2$$$
$$$10^n = (m^2)*k_2 + r_2*m + r_1$$$
$$$r = r_2*m + r_1$$$
$$$10^n = (m^2)*k_2 + r$$$
$$$r = r_2*m + r_1$$$
$$$answer = r_2 = (r - r_1)/m$$$
$$$answer = r_2 = ((10^n)\%(m^2) - (10^n)\%m)/m$$$
how is r = ($$$10^n$$$) % ($$$m^2$$$) ???
Meanwhile,
Then the answer is
let y be the answer(0 <= y < M), then the condition is: ( 10N — (10N)%M — y*M)%(M2) = 0
let 10N = q*M + r
we want q%M. Let this be y
So q = q1*M + y
Multiply M both sides
So q*M = q1*M2 + y*M
implies: 10N — r = q1*M2 + y*M
OR 10N — r — y*M = q1*M2
As q1 is integer, hence above condition.
Now how to solve B??
Ty, now i think im able to understand.
Create a graph of colors and keep deleting vertex with degree eguals to 1. In the end the answer is the number of vertex deleteds plus the remainders with degree greater then 1.
Any vertex wich has degree equals to one, has only one chance to be chosen. In the end of the process of retiring these vertex, vertexes that have degree bigger then 1 can be put in a cycle that make they be chosen.
I don't know how explain better, my poor english.
My submission: 19286958
your idea was very clear of showing up the color that occurs once(degree 1) and remove then from graph now consider others. but please would you like to explain what editorial said i am unable to relate it with this.
Every conected component with the number of edges greater or equals than the number of vertex has at least one cycle, so in the process of deleting vertex of degree 1 in this component , it will remain just vertexes with degree greater than 1, so all vertex of the component can be chosen.
In the case of there's no cycle in the connected component (when number of edges is the number of vertex minus 1), one vertex will remain without be chosen.
I think this is the way the two solutions are linked.
Amazing proof!!
Make a graph with numbers on cards as nodes and edges as cards. For each connected components, count the number of edges it has (repeated is counted twice, vertices of components only once). If number of edges for a component is greater than equal to the number of vertices for the component, then we can take all vertices as numbers on cards. Otherwise we can only take (number of vertices — 1) for the component as contribution to the answer.
I felt A took more thinking than B and C and D
Wow, I spent an hour trying to figure out how to calculate the sum of floors in E, and it turns out that Atcoder contestlib has a function to do exactly that???
Bullshit: https://github.com/atcoder/ac-library/blob/master/atcoder/math.hpp.
can anyone please explain what is wrong with this solution to D.
consider a single loop of nodes. your set of edges would contain 1 extra edge from the dfs root to one of its children
I am wondering why my solution to B is incorrect.
My idea: build a graph using $$$N$$$ nodes as cards and some other nodes as colors. Connect an undirected edge between two kinds of nodes when a card has a color on its either side.
Then I tried Dinic but got TLE. I thought of a linear method but it got 13 WAs. My code is Here, could anyone found what the problem is?
I managed to squeeze Dinic in by first removing all cards that connect to a colour that only appears once and adding the number of removed cards to the max flow. https://atcoder.jp/contests/arc111/submissions/19287109
Changing Dinic to Push Relabel makes it run much faster in only 316 ms :P
Submission
Wow. That's much faster. I wonder if Push Relabel is fast enough to work without this optimisation.
Could you elaborate? This is wa, isn't it?
Probably judge solution is incorrect. I guessed some common pitfall and got AC.
Ok I got it, it's like you answer the question in the title, ok haha funny
We found this during the contest :)
Maybe you were glad when you found the title "Do you like query problems?", then opened it, and ...
Thank you for participation!
xd
I liked it even though it was not a query problem. Thank you!
Can anyone please explain the time complexity of D without the constraint that guarantees the existence of a solution to me? From the editorial of D, it is $$$O(N+M+\frac{N(N+M)}{\sigma})(\sigma:wordsize)$$$ but I don't know why.
Soln remains the same. The additional step is checking if the found soln is correct. Given a directed graph, count no of nodes reachable from a particular node. That wordsize is a hint for bitsets.
Compress SCCs. It's a DAG now. dp[i][j] is true if j is reachable from it. Maintain bitsets for dp[i]. You can solve it in topological order of DAG.
Upd: To the ones downvoting above comment. It wasn't obvious. I had the same doubt when I first read this.
I completely forgot that this task gave $$$c_i$$$ for every $$$1 \le i \le N$$$ so that I was always thinking about the way to check if the graph was strongly connected. That's why I didn't understand this time complexity.
Anyway, thanks a lot for your help!
Can somebody explain how to get the idea that problem B can be solved by transforming it into a graph problem. I could never think that the problem relates to graph. Thank you.
For me, at first I had a wrong idea. But eventually got the solution. First, I thought for every card I can choose only one color — (a or b). May be I could solve it using bicoloring. So, started drawing a graph. And eventually realized it wasn't a bicoloring problem and found the solution that I need to check only if there's any cycle.
why to apply graph i dont understand we have to find max color showing on one side so can not it be like this https://atcoder.jp/contests/arc111/submissions/19280968
i know its wrong but why what i am not getting
Check this input
Your solution gives 2. But you can take colors 2, 1, 3. So ans should be 3.
AC Ouput: 4 (2, 3, 1, 4)
Can you give some test cases which fails my code. I try to solve it using SET but failed 2 tests. But could not figure out what cases it fails.
Problem E's maker has no wood!
不讲武德 :)
I just want to note that the final %m in the solution given at the end of the editorial for problem A is unnecessary.
can somebody explain why is this getting runtime error?
https://atcoder.jp/contests/arc111/submissions/19387114
a,b <=400000
Array visited[200000] is to small.
in my opinion, problem F should not have queries type 2