skull_crusher's blog

By skull_crusher, 7 years ago, In English

Hello Everyone!

We present you our Annual Programming Contest, CodeZilla, which is a part of BITOTSAV '17, the annual fest of Birla Institute Of Technology, Mesra. It will be a ACM-ICPC style 3-hour contest. Registration for the contest is free and open to all. Participation can be in teams of at most 3 members.

We promise you a really exciting and challenging set of problems!

The top teams will be invited for the Onsite finals.

Happy Coding :)

  • Vote: I like it
  • +32
  • Vote: I do not like it

| Write comment?
»
7 years ago, # |
  Vote: I like it +3 Vote: I do not like it

Gentle reminder : Contest is about to start :)

»
7 years ago, # |
  Vote: I like it +5 Vote: I do not like it

Nice problems :) How to solve Chef and Food Delivery

  • »
    »
    7 years ago, # ^ |
      Vote: I like it +7 Vote: I do not like it

    Take root of the tree as 1. Precalculate the number of children of each node.

    1. Calculate answer for the root.

    2. Now do a dfs traversal. Suppose x is the current node and y is the node to which we will go. Let e be the edge weight and child[y] represent the number of children of y.

    The paths till y will have their weights decremented by e (there will be a total of child[y] such paths)

    The paths till x will have their weights incremented by e (there will be a total of n-child[y] such paths)

    Code
»
7 years ago, # |
  Vote: I like it +4 Vote: I do not like it

How to solve chef and kites? And please make the solutions public.

  • »
    »
    7 years ago, # ^ |
    Rev. 4   Vote: I like it +22 Vote: I do not like it

    It is actually very similar to COCI 2016/2017 CONTEST #6 P5. You can build the mst only with n log n edges. First merge i and j for zero cost if a[i] % a[j] = 0, then for every distinct a[i], add edge between i and j with cost a[j] % a[i], if a[j] > a[i] * p, where p >= 0 and there isn't exist a[k] s.t. a[i] < a[k] < a[j], i.e. a[j] is the first number in a that strictly larger than a[i] * p. Total cost of the mst is the answer.

»
7 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Solution or hints for Hogathon ?

  • »
    »
    7 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Hi,

    well — not sure, whether it is correct (I hope so) but here's our approach.

    Two facts:

    A) You can use every node ([x,y]) just once

    B) The grind (under dominoes) is Bipartite Graph

    Well, from these fact one shall consider Matching :) Anyway:

    I) The matching is not maximal (just matching up to K)

    II) You are not interested in matching itself (it will in most cases be K) but for some value of it (you want maximal such value) => So we want matching with cost :)

    So what now — Let us consider following matching (capacity/cost):

    (Source1) → K/0 → Source2 →→→ 1/0 →→→ WhiteSquare →→1/INF-CostA-CostB →→ BlackSquare →→ 1/0 →→ Sink

    If you execute this matching [Min Cost Max Flow], and subtract it from "flow*INF", you will get the sum of squares you won't consider — so subtracting this value from sum of all squares will get the right answer.

    Well you might see a problem here: The size of parity is ~4.5*10^6 which is NOT sufficient for bipartite matching. But if you give it a small observation, you'll see, that there is no reason to consider ALL pairs of adjacent squares. Well if we consider optimal solution, it would be somewhere BETWEEN those pairs with the biggest sum of values.

    Off-course the most valued pairs might overlap, and it might lead to iniquity, so we shall find the bound of "enough" points (well or we can pick a VERY BIG VALUE {which is enough for mcmf}).

    SO: Get input → process all edges → sort edges be sizes → create reduced bipartite graph → do MCMF-algo → $$ Profit

    Good Luck & Have Nice Day!

    • »
      »
      »
      7 years ago, # ^ |
        Vote: I like it +5 Vote: I do not like it

      Hi. How many pairs have u picked for the optimal solution? I tried picking 40 paris but got wrong answer. How do you calculate to know how many is enough.

      • »
        »
        »
        »
        7 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Hello,

        well unfortunately I don't know.. :'( A teammate's option was "48" {I can't see through it} — but I've set the constant as "3000" [just to be sure] which worked fine

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Please move the problems to practice section for upsolving