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

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

First round of this year's COCI will take place today at 14:00 UTC.
You can find the full schedule for this season here and register for the contest here.

Let's discuss the problems here after the contest.

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

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

Remainder: Contest starts in less than 15 minutes.

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

How to solve D (Hokej)?

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

    I guess the sufficient condition is that:

    t[i] is the time of i-th player plays.

    1.0 ≤ t[i] ≤ M.

    2.sum(t[i]) = 6 * M.

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

    I think the following greedy works, but I don't have proof: let's sort the players by quality. Then make a 6 × n table (so it has 6 rows and n columns) and from left to right fill it greedily with players not exhausting their endurance. From this matrix calculate the needed things.

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

How long until final results?

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

How to solve C for 100pts? I thought about trie or hashing but couldn't implement it.

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

    Insert all passwords into a trie and then use bruteforce to check every substring of every password.

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

    For storing strings use unordered_map which is basically hashing

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

    Simple std::map passes too. I stored count of strings in a map, checked every substring of every string, and multiplied by the counts. It results in O(NM2log(N)) complexity, where M is the length of the strings, so about 3 * 107 operations. My solution passed with 0.49 s on worst case.

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

Why doesn't Nlog^2 N solution pass in E? (binary search + segtree) Also, what's the intended solution?

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

    I coded such a solution and got full points (slowest time 0.46s). Code

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

    Seems is intended. Sort the events and queries offline by values of x (number of stops) and process the remaining dimension (children's age) with a segment tree.

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

      I did O(nlogn) with online queries.

      I use a segment tree, where the base nodes are the children, and the values are the currently assigned drop off (INF by default). The upper nodes are min of their children. Updates are simple segtree updates.

      When querying I move right, or right-up (i. e. from v either to v + 1 or to v / 2. When I can't move neither way, or I reach a node with at most Y value, I stop. If the stop node's value is bigger than Y, then the answer is -1. Otherwise, I move left, leftdown or rightdown, (i. e. from v either to v - 1, v * 2 or v * 2 + 1) in this preferency order, such the node I move to, got value at most Y. When we reach a base node, it will be the optimal answer.

      Here is my code.

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

Does anyone know what "Illegal substitute!" mean in D, because I can't find the error in my code.

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

    It probably means you bring down and up the same person at one moment, which is illegal. So instead of a -  > b you do c -  > a, a -  > b.

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

    Do you remember the rule "but a player cannot enter the game, and then exit in the same moment, or vice versa"?

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

      I don't think that this is the problem, I checked it with this checker (I hope it's correct :D): checker Also it shouldn't happen with my solution.

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

        The test cases are open to download, so if you have time, and luck, you can check manually for something illegal. Or just send source code.

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

        Oops the checker was buggy, my bad. It's really the problem :D Sorry.

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

        Maybe there are bugs on lines 25 and 26.

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

Can anyone explain F solution?

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

    I wasn’t able to participate, so this might get wrong

    As the rectangles form a tree structure, our task is simplified to

    • Building trees
    • Querying for a node that contains given points

    If we do these fast, other stuffs are fairly easy.

    We can use sweep line to do that. In a BST (std::set) we store rectangle as an interval, sorted in order of lower y coordinate. To build a tree, we just need to find a parent. This can be done by lower_bound operation in insertion phase (lower y coordinate slightly less than current interval). Query can be done in simillar way. So this is solvable in O((n+m)lgn)

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

    You build a tree of the rectangles (they are the vertices). By this I mean that the parent of rectangle X is the smallest rectangle Y, which contains X inside of it. This can be done with sweep line on the X-axis using a segment tree for the Y-axis in time.

    Now for every paintball ball we find the smallest rectangle containing it. After that we add that we have colored this rectangle with color of the given ball (we simply add it to a vector for this rectangle or something like that). This again can be done in with sweep line in time.

    Well now we have a tree and some vertices already have colors for them. Well if we have colored vertex X in some color, all of its ancestors also are colored with the same color. From this we see that a rectangle (vertex) is colored with all colors in it's sub tree. This is a well known problem which can be solved in with a segment tree and DFS order or with "dsu on tree" (I used this).

    So the whole solution has running time of . Here is my AC code from the competition.

    PS: In my code both sweep lines are merged into one.

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

      I thought of the same thing, but I don't think you need to explicitly build a graph. You could create an array of sets std::set<int> S[MAXN] containing the colours in rectangle S[i], and iterate the rectangles in increasing order of size, merging the current rectangle's set with its parent's at every step.