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

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

We will hold AtCoder Beginner Contest 214.

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

We are looking forward to your participation!

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

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

Email Announcement

Uhm sure, that's one way to rid the world of 'beginners' :P

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

This contest is clashing with ICPC Amritapuri regionals. If possible please postpone it, otherwise many people like me who are participating in this ICPC regionals will not be able to participate.

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

i think count of 400 problems should be increased rather than 500 or 600.(beginner point of view)

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

RIP Problem :D

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

beginner contests become harder and harder...

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

How to solve D?

I've been trying some tree dp

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

    I did it using DSU. For each edge it can be maximum on a path only if every other edge is smaller than it, so we can sort edges in increasing order and solve only for a tree that consists of some prefix of edges. As you traverse the edges add them to the tree and increase answer by $$$w \cdot sz[u] \cdot sz[v]$$$, where sz[x] is the number of vertices in x's component.

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

    Assume all N nodes initially are disconnected now iterate over the edges sorted by weight and merging the nodes on the fly, and before doing the merging operation on an edge $$$(u,v)$$$ add $$$w_{u,v} \times C_u\times C_v$$$to the final answer, where $$$C_u$$$ is the component size of the component in which node $$$u$$$ is present

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

How to solve E ?

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

Isn't problem D similar to 915F - Imbalance Value of a Tree? And 915F has a solution that can calculate the maximum value and minimum value...

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

Similar problem to F

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

    Actually this gfg method is very precise, but I overcomplicated it and was not able to solve it during the contest. Although after the contest ended, I got a solution using graphs. Basically like this.

    for all i, store where the next character 'c' occurs. Then from ith index create an edge between ith index and the minimum index from (i+2) where character 'c' occurs. Do the same from 0th index. Initiaize the dp array to zero except dp[0] = 1. Then for all i, dp[i] = dp[i] + dp[j] (j belongs to the other end of all the edges before i ).

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

Can anyone provide some information about solving min cost flow with Dijkstra (is there a way to get rid of negative edges)? I have never seen anything about it...

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

    Yes, we can make all edges non-negative. Check this

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

    Let dis'[i] be the shortest path from 1 to i in the previous graph .

    And you want to calculate dis[i] in the new graph .Let h[i] = dis[i]-dis'[i] , so dis[i] = dis'[i] + h[i].

    And you can turn the edge u,v,w to u,v,w+dis'[u]-dis'[v] , you can find that w + dis'[u] >= dis'[v]. So you can use dijkstra to calculate h[i].

    Because the graph is a DAG in the beginning , so you can calculate dis'[i] easily .

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

I'm finally able to solve 6 problems in ABC, but now there are 8 total :(

Also, now that ABCs are substantially harder than before, maybe the rated range should also increase?

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

could anyone help me understanding why just dp on DAG not working in H?

Make dag, let dp[i] = path with biggest items ends at i

in one iteration set all dp -1, then set dp[scc[1]] = 0. then just fill it dp table.

backtrace path with largest dp[i], then make all items of vertex in path 0

fill dp K times.

My code : https://atcoder.jp/contests/abc214/submissions/25054504

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

how to solve bonus of B

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

...not sure

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

I solved E using bitset code

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

How to solve E?

please anyone help me.

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

E can be solved using splay tree / ordered set with binary search in O(nlog^2).

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

Can someone please tell me what's wrong in my solution to problem D(Problem link)? Here's my code(My code). Thanks in advance.

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

    the way you declared edges was the problem, you first declared it with some size and later cleared it then sorted it and iterated from 1 to n-1, which causes wrong indexing and cause other problems too, here I corrected it. ps: your merge function is not optimal, your dsu will be O(logn) for each operation instead of O(1), look at cp-algorithm(or any other site) for optimal implementation of dsu.

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

Can anyone explain how to calculate the sum of products of sizes in problem G using binomial coefficients? I can't understand where the formulas in the editorial code come from.

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

    There is a good AtCoder explanation stream on YouTube. Unfortunately it is in Japanese and Google auto translate is not good at all.

    Let's hope that pashka will do a stream on these problems soon.

  • »
    »
    5 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +18 Проголосовать: не нравится
    Editorial code ideia
»
5 лет назад, скрыть # |
 
Проголосовать: нравится +29 Проголосовать: не нравится

Here's an $$$O(n)$$$ solution to F I thought was cool:

Go from left to right and imagine that we're building a trie representing the possible words we can form. So adding a new word == appending a leaf. If we ignore the consecutive restriction, we can append $$$s_i$$$ to any existing node, except for a node which already has child $$$s_i$$$. So we add $$$total - cnt[s_i]$$$ each time.

This consecutive restriction simply means we can't append $$$s_i$$$ to a node we made on the last index, so the number of leaves we form at index $$$i$$$ becomes $$$total - cnt[s_i] - [\text{# nodes formed at }i-1]$$$.

  • »
    »
    5 лет назад, скрыть # ^ |
    Rev. 4  
    Проголосовать: нравится +16 Проголосовать: не нравится

    As a bonus, this only requires $$$O(\sigma)$$$ memory (where $$$\sigma$$$ = alphabet size). Excepting input... but even that can be obviated, as it can be easily implemented such that the program only knows the single character being worked on. Makes for a cute little finite-state automaton.

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

In Problem E, I sorted the ranges in the non-decreasing order of $$$R_j$$$ and tried to assign boxes greedily, i.e., choose box $$$i$$$ such that $$$i$$$ is the first available box in the range $$$[L_j, R_j]$$$. However, for each range $$$[L_j, R_j]$$$, finding this $$$i^{th}$$$ box proved to be a headache.

my attempt

Is there a better way to maintain this? Particularly, with better time complexity than that mine. Thanks for reading and answering!

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

    You did read the editorial?

    We iterate the boxes. While doing so, we add all balls (with the intervals) to a list that can be put into the actual box (that ist, the l[i]<= current box)

    Foreach box, we assign the ball with the smallest r[i]. We find that ball by using a priority queue.

    Whenever the list of balls (the priority queue) is empty we "jump" to the next ball, i.e. the next bigger l[i] value.

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

Could someone explain to me the approach in the editorial of problem F. Substrings? In the solution to the original problem, what does $$$dp[i]$$$ represents? At first I thought it was the number of substrings of $$$1st$$$ to $$$ith$$$ characters of $$$S$$$ such that the $$$ith$$$ character is marked and the $$$(i - 1)th$$$ character is not marked but I think I'm understanding it wrong as dp[1] = 0 instead of 1. I feel like it's something very basic but I just can't wrap my head around it.

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

chokudai, can you update the testcases in dropbox for ABC214 please? They are not updated since ABC207.

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

Did anybody implement problem F in O(N) using prefix sums? I'm trying to implement it but can't deal with the indexes.

UPD:

Implemented it, code for people who need
»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can anyone share a test case for problem E for which below logic fails.

  1. Sort the intervals in increasing order of their endpoints.
  2. Greedily assign a box to each intervals starting from the right most interval.
int ans = 1, cb = a[n - 1].second;
for (int i = n - 1; i >= 0; --i)
{
    cb = min(cb, a[i].second);
    if (cb < a[i].first)
    {
        ans = 0;
        break;
    }
    cb --;
}
»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

how to solve bonus for problem B ? i.e. 0 <= S,T <= 1e18

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

I'm curious as to why problem G has $$$N = 3000$$$ with mod $$$10^9 + 7$$$, since my solution is basically the editorial solution with FFT to speed it up to $$$\mathcal O(N \log^2 N)$$$. I've seen many ABC problems with FFT on them, so it seems weird not to have $$$N = 10^5$$$ with mod $$$998244353$$$, but maybe this was done to hide the solution? I attached my submission below.

Submission