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

Автор Sul_A., история, 11 месяцев назад, По-английски

As the highest non-red, non-alt-account person in the round, I feel it is my duty to supply the community with an editorial.

2168A1 - Encode and Decode (Easy Version)

Editorial

2168A2 - Encode and Decode (Hard Version)

Editorial

2168B - Locate

Editorial

2168C - Intercepting Butterflies

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

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

nice, I'll link this in the contest

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

Auto comment: topic has been updated by Sul_A. (previous revision, new revision, compare).

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

Auto comment: topic has been updated by Sul_A. (previous revision, new revision, compare).

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

For A2, you can just use 10 characters to encode each number since $$$n\leq 10^4$$$ and $$$|s|\leq 10^5$$$. Each number $$$|a_i|\leq 10$$$ since the max number $$$10^9$$$ is 10 characters.

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

nice contest,in the a2 i use a to k with map for number form 0 to 9.

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

For the last problem, a following greedy also work: firstly, we notice that is suffices that the players A and B agree on a function $$$f: 0, 1]^{15} \to [0, 1]^{20}$$$ that have the following property:

$$$ popcount(f(x_i) \oplus f(x_j)) \leq 1 \iff x_i = x_j $$$

In fact, the encoding from the editorial satisfies this property (this is easy to check).

This is because if the player B recieves some bitmask from $$${0, 1}^{20}$$$, he will be able to loop through all the possible inputs and see which differs at at most a single position and it will be unambigusly the correct input. In fact, the construction from the tutorial allows B to compute the input directly, without looping.

But we can do something much simpler: just assign values to all $$$f(i)$$$ s one by one with a greedy approach: take the first allowed bitmask and mark all other bitmasks in the popcount distance of $$$ \leq 2$$$ as unavailable. It turns out that $$$2^{20}$$$ is enough of a set size for this greedy to work.

Code: 347305056

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

    How do you know if assignment order is actually optimal, and maybe some better order exists that does the job in 19 bits or lower?

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

      I don't and I doubt it actually is optimal. I implemented the simplest greedy that came to my mind and it turned out it was sufficient. If this simple greedy had failed, I would probably then try additional heuristics, for example picking the available bitmask that has the most overlap with unavailable masks (to minimize waste). If several heuristics had failed, I would try to search for structured approach.

      Also, in this particular problem we have a ratio of $$$2^{20}/2^{15}=32$$$, so if each bitmask has 190 neighbors within distance of 2, we need to reuse each unavailable bitmask about 6 times, which seems doable for a simple greedy.

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

    Fun fact: the approach used for problem C described in the editorial has a well known name: Hamming codes. I'm unsure why the authors chose to leave this out. Anyway, there's also an awesome 3b1b video that describes the exact algorithm needed to solve this. Here's my code for reference.

    Also, a very similar idea shows up in this CSES problem, this EGOI problem, and the first suubtask of this CEOI problem.

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

Does your approach for problem C have a name? It is quite similar to Hamming code and almost as efficient as it (requires at most 1 more bit than Hamming codes).

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

    I believe it is basically Hamming codes, in the way it detect errors. In addition, $$$19$$$ bits is actually possible if we just ignore the last bit $$$s_{20}$$$ (because we know that there is at most one bit swapped, and usually error-detection (in this case) in Hamming codes doesn't require this bit afaik). My solution for this problem uses $$$19$$$ bits also.

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

      I've looked at your code and it seems using 20 bits.

      19 bits should be theoretically impossible because if you need to choose numbers $$$x_1, \ldots, x_{2^{15}}$$$ from a total of $$$2^{19}$$$ numbers s. t. their $$$f(x_i)$$$ are pairwise non-intersecting ($$$f(x)$$$ is the set of all numbers that differ from $$$x$$$ in at most 1 bit) you need at least $$$\sum\limits_{i=1}^{2^{15}}{|f(x_i)|} = \sum\limits_{i=1}^{2^{15}}{20} = 655360$$$ numbers to do so which is larger than $$$2^{19}$$$.

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

Communication Problems are very fun. Hope to see them in official contests.

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

For Problem A2, we can encode every number with its number of digits $$$+$$$ that number in string.

Like for example, $$$9999$$$ would be encoded as $$$49999$$$ $$$\rightarrow$$$ $$$ejjjj$$$.

This would work for $$$n \lt 10^9$$$, since for $$$10^9$$$ we would have ten digits, for $$$n=10^9$$$ we can just use some unused character like $$$z$$$ to represent it.

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

    I came to the same conclusion but after the contest tho.

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

    I thought of this idea and the base changing idea as well, but another similar approach could also be using some unused random character $$$( \gt j)$$$ in between converted numbers. This should give a similar effect but the result will be one character shorter.

    We could also combine this idea with the change of base approach, having start and end/length determining characters and using a lower base than 26. This might be overkill though. (Sorry for somewhat redundant reply, just wanted to share)

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

In the problem B, we actually only need to binary search once. Because it doesn't matter if we know the location of $$$1$$$, we only need to do one search to find the location of $$$n$$$, given $$$x$$$.

The minimal prefix will always contain $$$1$$$ but end in $$$n$$$ if $$$n$$$ is later in the permutation. The minimal suffix will always contain $$$1$$$ but begin with $$$n$$$ if $$$n$$$ is earlier in the permutation.

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

I wrote my code on the problem a2 and i encoded the numbers of 1234567890 to qwertyuiop and for each stopping a 'g' my code ran and the a1 was accepted but on a2 it said wrong awnser on test 9, what could be the reason for this? Is it because it ran out of memory or what im very confused

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

what could be the rating of A2? (if it was in a rated contest)

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

For B, we can run binary search only once. If the permutation has $$$1$$$ earlier than $$$n$$$, the shortest prefix that returns $$$n-1$$$ will have $$$n$$$ at its end. But what if not? Well, if not, no worries. Player B will only find shortest suffix instead of prefix and the $$$n$$$ will be at the beginning. So player A needs to only tell if $$$1$$$ comes before $$$n$$$ or not.

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

For problem B, I think it should be emphasized that $$$x$$$ is meant to help player B solve the problem.

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

For problem C I was trying the following approach: - always use 20 numbers so butterflies can't add - use 10 and 20 as flags for the start of a valid signal - if we find 9 numbers between start flags / after second start flag then that's our valid signal - map each n to the nth permutation of {1, 2, 3 ... 9} or {11, 12, 13, ... 19}

For some reason my code RTE's because it seems like I'm being given 2 inputs per test case 348270329 ...

Maybe I'm misreading the submission info tho idk

EDIT: nvm I just re-read the problem statement and realised that they sort the set before giving it back to you lol

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

Hello, I am interested in run-twice (communicative) problems and would like to create my own tasks in Polygon. Could you please publish a detailed guide on how to set up this type of problem, or share an example project in Polygon? Thank you.

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

Here is my solution without using base 26 386249871