Блог пользователя chokudai

Автор chokudai, история, 7 лет назад, По-английски

We will hold AtCoder Beginner Contest 144.

The point values will be 100-200-300-400-500-600.

We are looking forward to your participation!

  • Проголосовать: нравится
  • +38
  • Проголосовать: не нравится

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +15 Проголосовать: не нравится

problem D is hard for beginer contest.

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +7 Проголосовать: не нравится

why geometry !!!

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Doing all tricks to somehow get the equation, but still cannot solve D. I am still wondering how I cleared physics and maths in higher secondary :\

»
7 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +5 Проголосовать: не нравится

Does anyone else also feel that loading standing page on Atcoder(so not only on current contest) takes a lot time?

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can anyone explain problem D ??

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How do you solve F?

  • »
    »
    7 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +1 Проголосовать: не нравится

    My solution for F uses dynamic programming.

    First, we define dp(i) as the expected path length from node i to node N. Now, we can see a recurrence relationship for dp(i): dp(i) = (sum of dp(j) for all j such that there is an edge i -> j) / (number of edges that start from i) + 1.

    For each node, we consider the value dp'(i), which is defined as the maximum dp(i) with one outgoing edge from i not considered. By finding the largest dp(j), we can easily find dp'(i) in O(N). Then, we replace dp(i) with dp'(i) for each i, finding dp(1) each time. The minimum of dp(1) in all of these scenarios is the answer (take into account that if i has only one outgoing edge, dp'(i) can be skipped over, and we must also consider the case where no dp'(i) is used).

    Code: https://atcoder.jp/contests/abc144/submissions/8171347

»
7 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +28 Проголосовать: не нравится

5th place! Happy about that :)

Here are my solutions and thoughts:

A) Check if a < 10 and b < 10.

Solution: https://atcoder.jp/contests/abc144/submissions/8148768

B) Simple loop through possible values of a and b. Solution: https://atcoder.jp/contests/abc144/submissions/8150815

C) Consider a divisor $$$d$$$ of $$$n$$$. Then we can go from $$$(1, 1)$$$ to $$$(d, n/d)$$$ which will cost $$$d + \frac{n}{d} - 2$$$. So we just find the minimum of this expression for all divisors of $$$n$$$. Solution: https://atcoder.jp/contests/abc144/submissions/8153886

D) We can ignore the depth, so let $$$y = \frac{x}{a}$$$, then we essentially have a square with sides $$$a \ \text{cm}$$$ and $$$b \ \text{cm}$$$ that is filled with $$$y \ \text{cm}^2$$$ liquid. Now there are two cases:

(1) $$$y \le \frac{ab}{2}$$$. When we reach the angle $$$v$$$ where the liquid starts pouring out it will form a triangle with sides $$$c$$$ and $$$b$$$ such that the area is $$$y$$$. That is, $$$c = \frac{2y}{b}$$$. The angle in this triangle closest to the side $$$b$$$ will have an angle $$$90 - v$$$ so we see that $$$\tan(90 - v) = \frac{c}{b}$$$. That is, $$$v = 90 - \text{atan} \left ( \frac{c}{b} \right )$$$.

(2) $$$y \ge \frac{ab}{2}$$$. Let $$$z = ab - y$$$. Similarly, there will be a triangle with sides $$$a$$$ and $$$d$$$ such with area $$$z$$$ — but this time everything but to triangle is liquid. We can calculate the angle similarly.

The time used is $$$O(1)$$$.

Solution: https://atcoder.jp/contests/abc144/submissions/8165013

E) We first make an observation: If no training is allowed ($$$K = 0$$$) it always gives the optimal result of we let the members with the lowest consumption coefficient ($$$A_i$$$) eat the most difficult food (highest $$$F_i$$$). So we start sorting $$$A_i$$$ and $$$F_i$$$ such that:

$$$A_1 \ge A_2 \ge \ldots \ge A_n$$$

$$$F_1 \le F_2 \le \ldots \le F_n$$$

So with no training the answer is $$$\alpha = \max_i A_i F_i$$$. Now we do a binary search. It is clearly possible to obtain a score of $$$\alpha$$$ and impossible to obtain $$$-1$$$. To see if it is possible to obtain $$$x$$$ we do the following: For each $$$i$$$ we will replace $$$A_i$$$ with $$$A_i'$$$ such that $$$A_i' F_i \le x$$$. So $$$A_i' = \min \left (A_i, \left \lfloor \frac{x}{F_i} \right \rfloor \right)$$$. Hence we need to train $$$\sum_i \max \left (0, A_i - \left \lfloor \frac{x}{F_i} \right \rfloor \right)$$$ in total. If this is $$$\le K$$$ it is possible and otherwise it is not.

We will need $$$O \left ( \log \left ( \max_i A_i F_i \right ) \right )$$$ steps in the binary search and each step takes $$$O(n)$$$ time.

Solution: https://atcoder.jp/contests/abc144/submissions/8159504

F) This is a DAG where $$$1, 2, \ldots, n$$$ is a topological sorting of the nodes. Let's consider the case where we remove no edges. Then we can calculate the expected number of jumps from each edge in $$$O(m)$$$ time: It is $$$1$$$ larger than the average of it's outgoing children. With a formula:

$$$dist_i = 1 + \frac{1}{\left | \text{adj_list}[i] \right |} \sum_{j \in \text{adj_list}[i]} dist_j$$$

So we start by doing this. Naively, we could try to remove every edge and do the calculations which would lead to a running time of $$$O \left ( m^2 \right )$$$ since there are $$$m$$$ edges to remove and each calculation would take $$$O(m)$$$ time. We can improve this by noting the following: If we remove an edge going out from $$$u$$$ then we want to remove the edge going to the child $$$v$$$ with the largest number of expected jumps to $$$n$$$. Hence we only need to check $$$n$$$ cases instead of $$$m$$$ which leads to a running time of $$$O(mn)$$$ instead.

Solution: https://atcoder.jp/contests/abc144/submissions/8163431

  • »
    »
    7 лет назад, скрыть # ^ |
    ← Rev. 2  
    Проголосовать: нравится 0 Проголосовать: не нравится

    In problem E, as you say it is optimal to sort $$$A$$$ and $$$F$$$ like above. So I want to ask Will the array $$$A'$$$ remain sorted with every value of binary search? And could you prove it? If it won't be sorted then how to prove that it is still optimal?

    Thanks in advance <3.

    • »
      »
      »
      7 лет назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      $$$F_i$$$ is monotonically non-decreasing. So $$$ \lfloor \frac{x}{F_i} \rfloor$$$ is monotonically non-increasing. And $$$A$$$ is monotonically non-increasing. Thus $$$A'_i = \min(A_i, \lfloor \frac{m}{F_i} \rfloor)$$$ is monotonically non-increasing.

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +12 Проголосовать: не нравится

My solutions to all of the problems can be found at this link.

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I had a binary search idea for D but hadn't got enough time to code it out. Did anyone solve the problem using binary search?

»
7 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

please clarify me why my ans is wrong for C,&D for C

ans=ceil(-2+(2*sqrt(n)));

and for D

{ y=((2*x)-(a*a*b))/(a*a);

ans=(180/PI)*(atan((b-y)/a)) ; }

but still it shows wrong answer .... why???

»
7 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +5 Проголосовать: не нравится

As a junior high student, I think Problem D is unfair because we haven't learnt the arcsin function before the contest. But I conquered it so I'm not very unhappy. :D

PS: I cannot browse the standings page. Maybe my location(in China) matters?

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Problem D ruined my contest

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Brute force (with randomize and optimization) can pass problem F.

Code

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Why was this contest not shown in clist.by ?

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

https://atcoder.jp/contests/abc144/submissions/8178663

I've been doing binary search on Problem D, but I just couldn't get an AC. I cannot understand. Any help will be appreciated! Please Help

BTW I didn't miss the case when half of the capacity is tilted.

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

can anyone help what is the testcase no 9 , i.e. , 01-handmade-08 ? I keep getting WA on it.

»
7 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

I was stuck at F, as my answer was "-nan" in C++, to only realize later that the graph is actually an acyclic graph, need to read problems more clearly from now on, otherwise I did Infinite GP sum of a matrix, which may indeed sound absurd for this question.....

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

After solving this contest, I have realized that I actually can solve all of problems without lack of any knowledge. Before, I even didn't read statement problem F because I believe I didn't having sufficient knowledge to solve it.