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

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

Hi everyone!

I would like to invite you to my second Codeforces round, which I have created with my friends Ashishgup and Vivek1998299.

With that said, I bring to your attention our new Codeforces Round 548 (Div. 2) that will take place on 21.03.2019 18:35 (Московское время). If your rating is less than 2100, this round will be rated for you; otherwise, you can participate out of competition.

I would like to thank Ashishgup and Vivek1998299 for their help with preparing problems, vintage_Vlad_Makeev, mohammedehab2002 and Um_nik for testing the problems and cdkrot for coordinating our round. I would also like to thank MikeMirzayanov for the awesome Codeforces and Polygon platforms.

You will be given 6 problems and 2 hours to solve them. Scoring distribution will be announced later.

Good luck! :D

UPD1: Shortly after the contest, we'll be on the community Discord server to discuss the tasks.

UPD2: Score distribution is — 500-1000-1750-2250-2500-3000

UPD3: Editorial

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

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

Is there something wrong with the registration system before? I noticed that it said the contest will be rated for people whose rating is under 1900 on the registration page when I registered for this contest.The Candidate Masters who registered that time have the sign of out of competition. What should we do now? Should we register again or the administrator will help us fix the bug? Please fix it, thanks and wish all the participants have a good contest and get a good rating.

»
6 лет назад, # |
  Проголосовать: нравится -42 Проголосовать: не нравится

oh god PLEASE no useless math so we can participate .... i know we don't matter for you anymore but make an effort for us and don't bullshit us.
but i don't have much hope in this one as the problem setter is from india . oh well

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

Codeforces round by an Indian coder. I am really exciting for this contest.

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

Let's hope for a contest with awesome questions with strong pretests !!!

»
6 лет назад, # |
  Проголосовать: нравится -12 Проголосовать: не нравится

Squad is Back on the occasion of Holi.

Super Excited.

»
6 лет назад, # |
  Проголосовать: нравится -12 Проголосовать: не нравится

Contest on Holi.

Confused whether to be happy or to be sad.

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

    Anyway it doesn't matter, You won't be busy hitting colours at 9:05pm (IST) in the night.

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

Is there a separate discussion forum for Codeforces or do people have to write blog entries?

Does anyone know if Topcoder has the same functionality as Codeforces like being able to solve past problems, submit solutions for testing, viewing other people's solutions filtered by language sorted by executions time, etc.? Topcoder website seems like a disaster. I would ask this in the Topcoder forum except I can't find a way to make a post there and there customer support seems unable to help. Thanks.

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

    Yes, it has most of it, but you need to download and launch Topcoder Arena

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

      Thanks. Is there a separate discussion forum on codeforces or do I ask questions on Round blogs like this?

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

holi .

»
6 лет назад, # |
  Проголосовать: нравится -22 Проголосовать: не нравится

it is too late for our Chinese students ( ̄_ ̄ )

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

    Because it needs to consider the time in Russia and the time in the author's country. It is late for Chinese students sometimes, but whether you participate in it or not still depends on you. You can balance your study, sleep and the training and the contests. If you really want to join the contest, just do it. If you are worried about the time and will not join it, you still can virtual participate or just practice the problems when you are free.

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

      There is no doubt that I will participate in it,because I really enjoy it.However it just goes against my original intention of wanting a healthy life. :D thanks for your reply.

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

Should the pretest be strong enough or not ??

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

I think this contest will be harder than div 3

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

I want to add some scores ^_^

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

Jeel_Vaishnav thanks for contest

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

Раунд от индуса..........

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

Why "fidofido" is the bad word?

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

Woow this round, I will fall) but its doesn't matter, because it will "FUN"!

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

Hi guys! Unfortunately CF-Predictor doesn't work in last version of Chrome. They changed Cross-Origin Read Blocking policy and my extension can't send requests to the backend anymore. But the actual problem is that I can't update code and fix issue ASAP. I recently started working in Google and they have pretty strict policy about open source projects. I'll try to come up with some solution, but sorry terms are unknown.

Current solution is to use website version.

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

    What about Firefox? Is the extension working there?

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

      Yes, I suppose so. It even can works in Chrome if it doesn't updated yet.

      You can just open any past contest and if you see additional column with rating change, extension is working.

»
6 лет назад, # |
  Проголосовать: нравится -14 Проголосовать: не нравится

Complexity distribution is so balanced

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

Nice Problem D!

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

»
6 лет назад, # |
  Проголосовать: нравится -9 Проголосовать: не нравится

What is wrong with the pretest 8 on problem C?

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

    I think you have not taken care of adding 10^9+7 while subtracting and then taking mod.

  • »
    »
    6 лет назад, # ^ |
    Rev. 2   Проголосовать: нравится +1 Проголосовать: не нравится

    you might be doing (total-calculated_value)%mod, which gave WA to me , but using (((total-calcualted_value)%mod )+mod)%mod which gave AC,hope it may help.

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

D is a very cool problem

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

.

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

During the contest, I got alot of "codeforces is temporarily unavailable" page and the problem was taking a lot in order to show anyone face the same issue like me?

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

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

when you don't want to solve graphs problems but cf has another opinion

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

A lot of people were saved by the authors from being hacked on A due to integer overflow.

»
6 лет назад, # |
  Проголосовать: нравится -14 Проголосовать: не нравится

PROBLEM C IMPOSSIBLE WHY WA??

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

who is the setter of problem d ? Ashishgup ?

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

Million dollar question-How to solve D?

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

    for each number g you have to find 3 things:

    a = how many numbers are relatively prime to g within range [1,m]

    b = how many numbers will have gcd g again when paired with g within range [1,m]

    c = how many numbers have gcd<g when paired with g. (This was the hardest part for me in this problem)

    The rest is calculating E(g) with a bit of knowledge of probability

    My code: 51649595

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

Is there O(n*k) solution for C? Or the constraints were there just to bamboozle innocent people like me? :)

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

    No need to count connectivity of red edges. Merge all nodes with red edges to components and multiply each member count of adjacent components

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

    Just a linear time solution. O(n)

    Count the number of bad strings, and subtract them from total (n^k) to get the final answer.

    Think how you can form a bad string, which doesn't traverse through any of the black edges. For simplicity remove the black edges from the graph and then, you'll get some connected components.

    To Form a Bad string of length K, all the nodes should be from the same component. If you take nodes from different components, they must have to traverse through a black edge and hence it will not remain a "bad string".

    Now suppose cnt = no. of nodes in a connected component. Then no. of bad strings formed by nodes of that particular connected component is = cnt^k

    Total no. of bad strings = sum of bad strings of each component.

    Note : If the difference is less than 0 after taking modulus with 1e9+7, Add 1e9+7 to make it positive.

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

One minute silence for the three Indians: alwaysGREEEN, Abhinaviitbhu and imhemant.
Who were the only people to get hacked today, on the occasion of holi.

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

How to solve C?

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

    First, notice that this is an inclusion-exclusion type of problem. So the answer will be something like: all possible permutations — all impossible ones. After realizing that, you'll soon notice that all the impossible ones are the collection of nodes that don't have any black edge at all.

    Hence, we can simply isolate collection of nodes by using disjoint set. Simply merge when the edge is red and skip the black edge. When you have got a bunch of disjoint sets, you can calculate how many permutations can be constructed from a disjoint set of size x. pow(x, k)

    The total answer would be pow(k, n) — (for each disjoint set of size x, pow(x, k))

    Solution

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

Can someone explain how to solve C

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

    lets do tree with only RED . we have forest and answer is n ** k — a1 ** k — .. — af ** k, whee ai number of vertexes in i tree

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

    Count how many sequences are bad (not good) and subtract it from N^K. If we make the graph only with red edges, for each connected component with size X we will get X^K bad sequences from this component. Sum of bad sequences for each component will give total number of bad sequences. It's not possible to get any more bad sequence because merging any two component would need black edge which we can't use in bad sequences.

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

How to solve E?

  • »
    »
    6 лет назад, # ^ |
    Rev. 2   Проголосовать: нравится +30 Проголосовать: не нравится
    Spoiler1
    Spoiler2
    • »
      »
      »
      6 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Thanks a lot!

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

      Is this the right approach?

      We start with a bipartite graph with 0 potential vertices on the right. We will first add all persons that were never removed to the clubs on the left. We will process the days in reverse order. We will add the person that was removed on this day to our bipartite graph after we have processed this day. As long as the bipartite matching is maximal, we add the first available potential (first 0, then 1, then 2, etc) to the bipartite graph and rerun the matching algorithm. When the matching is not maximal anymore, the final value we tried to add is our MEX value for this day. The MEX can only increase during this process, so we never have to remove added potentials anymore in the graph.

      Edit: solved while processing the days in chronological order with a similar approach as described above (but instead of adding potentials, we remove them when the matching isn't maximal). https://mirror.codeforces.com/contest/1139/submission/51653759

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

      RobeZH, how are you calculating mex using bipartite matching. Can you please explain. Thanks

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

        First we build a graph to check that whether the mex can be 1 (, more specifically, say we put the potentials on the right hand side of the bipartite graph, we build it such that only potential 0 is connected to the sink, and see if there is a perfect matching). If yes, we incrementally build the graph to check that whether the mex can be 2, and so on. If no, we know that the previous number is the mex for the current set of people.

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

Help me solve problem B, My solution O(n^2) :'(

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

    You can solve it in a single iteration from n-1 to 0, making it O(n).
    Check my simple solution.

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

    Think greedy.
    Use the maximum possible number of chocolates from a_n and with considering the picks use the maximum possible number of chocolates from a_n-1 and so on...

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

Can some one help me with problem D?
I got wrong answer on test 13.
Here's the code

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

Today's problem C, is the first tree problem I have solved till date without traversing (dfs/bfs) the tree.

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

    How so?

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

      I used UFDS (Union Find Disjoint Set).
      Check my solution.

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

        Oh, yes, I forgot about DSU solution.. But that means that you are expert and never solved MST problem, wierd.

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

          I am talking about exclusive tree problems usually given in cf.
          I believe MST is found on a given general graph.
          Or maybe I just don't remember. Thanks for judging me :)

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

            Can you talk a little about your solution using DSU?

            • »
              »
              »
              »
              »
              »
              »
              6 лет назад, # ^ |
                Проголосовать: нравится 0 Проголосовать: не нравится
              1. Merge all the nodes connected by red edges into disjoint sets.
              2. Find the no of sequences of size 'k' formed by each of the disjoint sets individually and sum all of them.
              3. Answer will be n^k -the sum found in step 2.
              4. Also keep in mind we need to subtract sequences with all nodes same.

              Check my solution for more clarity.

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

    In fact, it can be solved by just dfs.

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

How to write code to hack others? I use this code to hack problem B, why the return is "Invaild input"?

include

using namespace std; int main() { int n=100000; printf("%d\n",n); for(int j=n;j>=1;j--){ int t=10000000-j+1; if(j==n){ printf("%d",t); } else printf(" %d",t); } return 0;

}

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

Nice set of Problems. Three cheers to the authors :D

Already waiting for the Editorial. Please publish them soon :)

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

What is the intended solution for D? I managed to pass the pretests with inclusion-exclusion and some optimisations.

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

    My solution was calculating the probability of obtaining an array of length n with the gcd of the array(except the last elemnent) as x with ending element y where $$$x,y \in [1,m]$$$, $$$ n \in [1,\inf]$$$ and y is coprime to x.
    Then, summed up the contributions with a bit of math.

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

Problem E: The mex of the multiset S is the smallest non-negative integer that is not present in S. For example, the mex of {1,2,3} is 0. Why the mex of {1, 2, 3} is not 4?

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

Problem C: Count connected components of red nodes. If a connected component has p nodes. Impossible paths are p^k, sum similarly for all connected components. Finally subtract this value from n^k, also subtract no of nodes that have zero red edges. Is my idea anywhere close at least? I couldn't manage the time to implement though..

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

can E be solved by maximum matching?

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

can prob E solved by bipartite match?

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

    Yes. But there is tricky part, it is not just reduction to maximal matching problem.

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

      so sad...

      When I recognised how to solve this problem, it was 10 minutes before the conteat ends.

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

It was a very unbalanced round. The jump in difficulty from B to C was to great. The problems were interesting but I felt like there should have been a problem between B and C.

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

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

I made an idea for Problem D and couldn't implement it for 1 hour 30 minutes XD

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

    why ?

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

      My idea is very hard to implement(at least for me).

      My solution idea for D:

      1. We can define the weighted/directed graph to solve this problem. Each node has distinct set of primes. This means the prime divisors of greatest common divisor made by array $$$a$$$ so far. For example, if the $$$a = [24, 30, 18]$$$ then the state of $$$a$$$ is $$$(2, 3)$$$. Of course there can be self-looping edge exist.

      2. There is a special node called all, this node contains all prime numbers in $$$[1, m]$$$. For all non-special nodes there is an edge exists directed from all to that node.

      3. Calculate weight of all each edges, then you can solve the equation such like; $$$EX(node) = 1 + \sum_{\text{all neighbors}}^{} EX(neighbor) * weight$$$ where $$$EX$$$ means the expectation of length of sequence started from that state. There is an exception; $$$EX(NULL) = 0$$$.

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

      Example for $$$m=10$$$

      • all -> null: 1 (1), [2]: 3 (2, 4, 8), [3]: 2 (3, 9), [2, 3]: 1 (6), [2, 5]: 1 (10), [7]: 1 (7), $$$EX(ALL) = 1 + 0.1 EX(NULL) + 0.3 EX([2]) + 0.2 EX([3]) + 0.1 EX([2, 3]) + 0.1 EX([2, 5]) + 0.1 EX([7])$$$
      • [2] -> [2]: 5 (2, 4, 6, 8, 10), null: 5 (1, 3, 5, 7, 9), $$$EX([2]) = 1 + 0.5 EX([2]) + 0.5 EX(NULL)$$$
      • [2, 3] -> [2]: 4 (2, 4, 8, 10), [2, 3]: 1 (6), [3]: 2 (3, 9), null: 3 (1, 5, 7), $$$EX([2, 3]) = 1 + 0.4 EX([2]) + 0.1 EX([2, 3]) + 0.2 EX([3]) + 0.3 EX(NULL)$$$

      You can find weight of all edges with fast factorization.

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

      More simple example $$$m=4$$$

      • all -> null: 1 (1), [2]: 2 (2, 4), [3]: 1 (3), $$$EX(ALL) = 1 + 0.25 EX(NULL) + 0.5 EX([2]) + 0.25 EX([3])$$$
      • [2] -> null: 2 (1, 3), [2]: 2 (2, 4), $$$EX([2]) = 1 + 0.5 EX(NULL) + 0.5 EX([2]) = 2$$$
      • [3] -> null: 3 (1, 2, 4), [3]: 1 (3), $$$EX([3]) = 1 + 0.75 EX(NULL) + 0.25 EX([3]) = \frac{4}{3}$$$
      $$$EX(ALL) = 1 + 0.25 \times 0 + 0.5 \times 2 + 0.25 \times \frac{4}{3} = \frac{7}{3}$$$
»
6 лет назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

Thanks for awesome problemset and super fast system testing !

I have enjoyed the contest a lot.

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

if a problem submit twice, all accept, which is the score in the problem?

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

Why is this invalid input for hacking A? Why is this N^2 solution passing for A?? Please help.

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

I was kind of confused by problem B, it implies you can decided to buy a chocolate or not, but in reality you always buy a certain chocolate, even if 0 times...

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

Can anybody tell me how to solve problem D? I was thinking to solve it like E[len]=E[number of 1's]+E[number of 2's]+E[number of 3's]+------E[number of n's] in the sequence but could not able to solve it.

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

In problem D, can someone explain the solution with mobius function?

My solution is $$$\sum_{i=1}^{\infty} i*q^i = q / (q-1)^2$$$, and the answer is $$$\sum_{i=1}^{m}mu[i] * q / (q-1)^2$$$, $$$q=[m/i]/m(i=1\dots m)$$$, but it is wrong :(

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

When will tutorial be out?

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

[Problem B] I just realized I didn’t understand the task properly. But now I wonder if there is a nice algorithm to solve the version of this problem that I had in mind.

So the condition is such that the number of chocolates we buy has to be a strictly increasing segment. In particular we are allowed to leave some types of chocolates on the right side. For example:

5
1 2 3 1 1

Should produce 6.

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

    I had the same misconception in the beginning, couldn't thing of anything better than O(N^2).

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

    Same happened to me. Lost a lot of time for not reading again the problem statement.

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

    Couldn't solve it because I understood the same.. After almost 2 hours thinking i'm pretty sure there isn't anything better than N^2.

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

I liked the C priblem a lot. At first I found it difficult to solve it, but after that i understood it was easy.

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

Please publish the editorial as early as possible. Can't wait to see the solution of problem D, E and F!

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

Thanx. Nice problems. It is good that in pretests exists test for TLE, at least for E. There is happen that seems like optimization do not need, but pretest got TLE and one saves time for testing and will not get disappointment after contest.

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

How did (n*n) solution got accepted in Q A? Link https://mirror.codeforces.com/contest/1139/submission/51625556

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

I know that E's Solution is Khun's algo with reversing queries, but I am interested to know was there any direct HopcraftKarp Solutions that passed it should be $$$O(N^2sqrtN)$$$, since the number of edges <= 5000 and the number of nodes <= 5000 that totals to $$$\cdot{2*10^9}$$$ operations approx.

but as I don't really understand how HopcraftKarp works I am not sure can it be optimized to pass?

  • »
    »
    6 лет назад, # ^ |
    Rev. 2   Проголосовать: нравится +8 Проголосовать: не нравится

    I think if we use Hopcroft Karp we need to binary search on the answer and so we attain complexity of $$$O(N^2 \cdot sqrtN \cdot logN)$$$. Can you explain your approach of using Hopcroft Karp and attaining complexity $$$O(N^2 \cdot sqrtN)$$$?.

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

      Sorry, apparently I really didn't understand Hopcroft Karp that well, a friend of mine explained it to me afterward and told me that a simple $$$O(N^2sqrtN)$$$ Hopcroft Karp is not doable.

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

I am getting TLE on pretest 6 in Problem A. Please help. Link to the submission. In this code I'm taking each substring and just checking the last digit is even or not. Is it not one of the right way to do so?

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

    Your complexity of solution is O(n^2) and I guess java is slower than c++ and the multiplier for java might not be enough for an O(n^2) to pass but in c++ it is, just bad luck i assume!

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

Why did my Submission 51646792 fail? Does it have something to do with modular arithmetic?

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

I am getting WA on pretest 10 in Problem B. The longest testcase, I suppose. Link to my submission. Please Help.

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

Can someone check if my solution for E is correct? It's not maximum matching.

First, I find max mex for the given situation without considering updates. Here's how I do that: I go from $$$0$$$ to as far as I can go by randomly picking a club which has a member of the required potential. When I choose the $$$i$$$'th club for potential $$$j$$$, I make a directed edge from all other clubs who have a member with potential $$$j$$$ to $$$i$$$. Now, if I get stuck at some potential k, I will bfs from the unused clubs to find a club which has a member with potential $$$k$$$. Now, if the path to this club is like $$$p_{x}$$$ -> $$$p_{a_{1}}$$$ -> ... -> $$$p_{y}$$$, where $$$p_{x}$$$ is the unused club and $$$p_{y}$$$ has a member with potential $$$k$$$, I can replace $$$p_{a_{1}}$$$ with $$$p_{x}$$$, and $$$p_{a_{2}}$$$ with $$$p_{a_{1}}$$$ and so on. After this I update the edges of the graph as required. By the end, I will find the max mex for the given situation.

Now, for updates: First notice that the max mex can only decrease or remain same. Now, I maintain the reverse of the graph I mentioned above, if a member from club $$$i$$$ is chosen for potential $$$j$$$, then I make a edge from club $$$i$$$ to every other club which also has a member with potential $$$j$$$. Now, for each member which leaves, we see if we were using this member in our chosen max mex, if not, we do nothing. If yes, then we bfs from this club to either find a club which is unused right now (in which case max mex remains same) or we find a used club from which we have taken a member with the highest potential (in this case max mex becomes this new potential). In both cases we update the entire graph again as required.

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

My solution for C runs in O(nk) time and it still TLEs, does anyone know why it exceeds the time limit

https://mirror.codeforces.com/contest/1139/submission/51649583

edit: I found the reason: apparently running a DFS has a much larger constant than I thought. I ended up passing by precomputing the DFS order and then doing DP directly on that

https://mirror.codeforces.com/contest/1139/submission/51920785

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

In Problem D how to find no of possible ways to get an array of length k with gcd say x

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

    You need to get needed prime divisors and avoided prime divisors. That's the key.

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

Hello, Div.2, my old friend

I've come to solve your tasks again...