We will hold AtCoder Regular Contest 163.
- Contest URL: https://atcoder.jp/contests/arc163
- Start Time: http://www.timeanddate.com/worldclock/fixedtime.html?iso=20230702T2100&p1=248
- Duration: 120 minutes
- Number of Tasks: 6
- Writer: PCTprobability
- Tester: maspy, Nyaan
- Rated range: — 2799
The point values will be 300-400-600-700-900-1100.
We are looking forward to your participation!
Lost 80% of contest time by only thinking. depressed :(
How to solve C/D ?
C.1 = (sum(1/(i*(i+1))) where 1<=i<=n-1 ) + 1/n. But it doesnot work in some cases, (where n = k(k-1)). You must fix this.
Proud to submit B at the last second and got accepted! :)
congratulations
I also submitted B in like the last 10 mins, got AC× 11,WA × 3,TLE × 25. got pretty devastated.
Problem F is the same as this
"Well-known in China" moment
Cool C & D, i get like 5 WA's on B, because don't think about case A[0] > A[1] ....
$$$C$$$ is interesting problem. We can notice that $$$\frac{1}{x} = \frac{1}{x+1} + \frac{1}{x(x+1)}$$$. This will be the only transition from $$$n$$$ to $$$n + 1$$$ — we will remove some $$$x$$$ and insert $$$x + 1$$$ and $$$x(x + 1)$$$. Since the size of set is $$$< 500$$$, with high probability there will be no both these numbers.
My solution is:
anyone get why https://atcoder.jp/contests/arc163/submissions/43201545 does not work for C?
asserts should ensure it works well + bruteforcing on all cases reveals no issues (i.e. all criterias are satisfied IMO).
Idea is quite similar, just the edge cases ($$$N = i * (i + 1)$$$) are handled slightly differently,
I am not quite confident, but I find that for n=6, your output is not correct.
I think you should construct a solution for n-2 in the special case(where N=i*(i+1)) and then replace the largest number x in that solution by 2x,3x and 6x.
alternatively, construct for n — 1, and then replace the highest term by 3/2x, 3x, it can be seen its always divisible by 2
I saw the editorial is written by GPT-4. Was it generated from only problem, or from essential describing of solving method?
Edu was first written in Japanese and then they were translated through GPT.
How to solve B?
two pointers
Not helpful, care to explain?
hint : store and sort the elements except 1st and 2nd element in an array then check every m size subarray , for each subarray check minimum operation required to have all those m elements of the subarray between modified / unmodified A1 & A2 ; minimum of them is the answer
thnx
whats wrong in my code?
awareness tip : next time when you will code in usaco ide make sure you create a new file and code there or make the file that you shared private otherwise people can easily view your code during ongoing contest
Would anyone like to talk more about problem D. I read that "theorem" in the editorial, but I don't quite understand. For instance, it says that if s1,s2,...,sk form a strongly connected component, then A and B satisfy the condition. But, we have an edge from sk to s1, and this means that there is an edge directed from B to A, which is against the condition?
My understanding of the editorial:
SCCs (s1, s2, ... , sk) form a DAG.
Let's arrange these SCCs so that iff i < j, then s_i is topologically earlier than s_j. With such an arrangement there may not be any edge from sj to si, if j > i, as that would lead to a contradiction (as sj is later in topological order).
Note, that as it's a tournament, there exists a single topological ordering of the SCCs, as there is always a directed edge between any pair of vertices.
So we can safely divide SCCs into sets A = { s1, s2, ..., si }, B = { si+1, si+2, ..., sk}, so that they meet the conditions. And there will be exactly K+1 such divisions into two sets of SCCs as we can choose any i in range [ 0, k ].
s1,s2,...,sk form a strongly connected component
Here is the misunderstanding. According to the editorial, (s1,s2,...,sk) do not FORM a strongly connected component. (s1, s2, ..., sk) ARE LABELS for all the strongly connected components in the graph.
Thank you so much! I thought that s1,s2,...,sk are nodes but in fact they denote SCC. Now, I would like to try to understand the editorial again.
I did something different, although I didnt manage to debug and AC within contest.
Basically, my dp state was dp[n][cc][m] = how many different graphs of n vertices have cc connected components and m edges from small to big. Once u have that its just simple math.
The transition then is take k vertices to form the 1st CC in the DAG, suppose it has m1 s->b edges, and suppose the 1st CC to the rest of the CC have m2 s->b edges and the remaining CC-1 components have the rest (m — m1 — m2 edges). If you get the 3 parts, you can just multiply all 3 and add to dp[n][cc][m]. So ull add something like (ways to pick k vertices with m2 as described above)*dp[k][1][m1]*dp[n-k][cc-1][m- m1 — m2]
Also u cant compute dp[n][1][m] directly, but you can get it via C(n*(n-1)/2, m) — dp[n][2][m] — dp[n][3][m] — etc. (Or maybe there is a combinatorial argument that eludes me)
For the ways to choose the k vertices, basically its the number of multisets such that k numbers from 0 to (n-k) such that it add up to m2. (You can write a dp for that, I dont know of a formula, bars and stars is ordered which is not what we want)
Depending on how u do it, it can take very long (like O(n^10)), but what I realised after the contest was that by reordering the loops, u can do convolution on the results of the 3 parts to get the result fast, instead of having 3 for loops (which is O(n^6)) and reduce to just O(n^4) or O(n^2logn) with NTT. Link: https://atcoder.jp/contests/arc163/submissions/43206412
My code (according to the editorial):
C can even be found on search engines. Hope to see more interesting CP problems instead of well-know math problems.
link please
You can find the sol in this video->link Also, the key equation can be found easily by searching "Egyptian Fractions" on search engines.
I didn't know that GPT-4 is smart enough to solve E
How Does checker of problem C work?
long double has accuracy upto 18 digits, right? and we need accuracy upto 9 digits for numbers between 1 and 1e9.
untrue, taking only 9 digits is not enough, for example 9, 9, 9, .... 9(9 nine times) is correct (ignore equal rule break) and 9, 9..., 9, 1e9 is not correct but you will mark exactly opposite
What I meant was something like
returns true for the first case u mentioned, and false for second
edit: hm you're right 9 digits are not enough because of upto 500 different additions.. still, 12 digits would do and we hv 18 digits (more than enough to guarantee correct answer)
(2, 4, ....., 2^n, 2^n) adds to 1
(2, 4, ....., (2^n) — 1, (2^n) + 1) gives a difference of the order 1e-25 according to my computer (for n = 28)
one must always be careful of making such analysis without really giving any reason for why its correct.
modulo hash fractions should work
Note that the sum $$$1/a_1 + 1/a_2 + \dots + 1/a_n$$$ can have a denominator of about $$$(10^9)^n$$$, so it can be super close to $$$1$$$, while not being $$$1$$$ exactly.
The bounds are low, so the checker can just calculate the exact fraction using big number arithmetic. It will only need the plus and times operations on bignums, and use those bignums in a fractions struct. It can be implemented without that much pain in C++. (If it is possible, I would do it with Python.)
A fast way to do it is divide and conquer. So calculate the exact fractional sum for the left halve and right halve of the array, then add those two. This ensures most additions of fractions are done on small fractions, and only the last few additions are really done on really big fractions.
how to handle a[0]>a[1] in B?(0 based indexing)
In that case, at least one of the endpoints will have to be modified (either the lower bound (
a[0]
) is greater than the minimum element or the upper bound (a[1]
) is smaller than the maximum element for any elements ina[2..n]
). The core of the solution does not change in this case.Problem F is exactly the same with my idea.