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

Автор Egor, 15 лет назад, По-русски

Финал Google CodeJam состоится 29 июля в 4:00 по Москве

Рассказ одного из участников Первая часть, Вторая часть
Теги gcj
  • Проголосовать: нравится
  • +17
  • Проголосовать: не нравится

15 лет назад, скрыть # |
 
Проголосовать: нравится +12 Проголосовать: не нравится
Good luck in defending your title, Egor!

Any advice for the rest of us mere mortals on how to go about improving our problem solving skills, so one day we too can make it to the on sites? And yes I know the "practice a lot" one :) May be something related to mathematics? I am thinking nowadays about going for an MS in Mathematics, just so I become good at algorithm contests ;)


15 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится
У меня вопрос про футболки.

Сегодня получил футболку Russian Code Cup - а это, как и было где-то уже написано, маломерка.

Так вот, во избежание, что можете сказать по этому поводу о гуглофутболках? Они нормального размера?
15 лет назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится
What is the main place where the spectators discuss what's going on?
15 лет назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится
Apparently the contest gets postponed over and over again :)
15 лет назад, скрыть # |
 
Проголосовать: нравится +10 Проголосовать: не нравится
Still no submissions at 15 minutes. Apparently the problems are tough, good!
15 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится
Four people with non-zero scores now, all from Russia: pashka, Evgeny Kapun (no CF handle?), RAD, vepifanov.
15 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
There's also a long-standing attempt at D-small which I guess was unsuccessful since it's been more than 4 minutes.
15 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
ivan.metelsky gets A-small.
15 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
More than an hour into the contest, still just 11 contestants with successful submissions.
15 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
1h18m - pashka still leading with 30 points. He was in the lead (shared for the first 25ish minutes) during the entire contest so far!
15 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
ACRush and vepifanov now have non-zero scores on two problems. Both just small inputs yet, though.
15 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
Wow, an unexpected submit from voover - I didn't even know he was participating - apparently somebody from http://apps.topcoder.com/forums/?module=Thread&threadID=706558&mc=114#1387375 couldn't make it.
15 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
Somebody else has attempted B-large. We'll learn who in 8 minutes :)
15 лет назад, скрыть # |
 
Проголосовать: нравится +19 Проголосовать: не нравится
That long silence from rng_58 was for a reason - E-small+E-large and tentative second place!
15 лет назад, скрыть # |
 
Проголосовать: нравится +12 Проголосовать: не нравится
winger submits A-small and we now know that the unknown wrong on E-small was due to him. 

zyz915 submits B-small and the unknown wrong there was probably due to him.

There are no more unknown wrongs, and darnley is the only one with no submissions.
15 лет назад, скрыть # |
 
Проголосовать: нравится +17 Проголосовать: не нравится
Meanwhile, we have a new leader - ivan.metelsky leads with 77 points by solving D-small. If we add up points for all datasets solved by at least one contestant, though, we get 140.
15 лет назад, скрыть # |
 
Проголосовать: нравится +12 Проголосовать: не нравится
47 minutes to go, 3 people with 77.
15 лет назад, скрыть # |
 
Проголосовать: нравится +20 Проголосовать: не нравится
darnley is the first to solve C-small - here is the reason for his silence!

Meanwhile, rng_58 leads after solving A-small and A-large with 90 points.
15 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
But meret retakes the lead with B-large and 100 points.
15 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
And the contest is over with no major changes at the top. meret with 100, then rng_58 with 90, then ivan.metelsky with 77. Let's wait for the large results to be revealed.
15 лет назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится
похоже на то, что Petr установил новый рекорд в социальной сфере Codeforces, оставив 31 комментарий подряд =)
15 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Не тот язык.
15 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится
Problem C is brilliant! I think it is the best Code Jam problem I ever seen. The idea is original and fresh and the code is quite short, however it requires careful implementation. Quite strange that only one person has tried to submit it.
  • 15 лет назад, скрыть # ^ |
    ← Rev. 2  
    Проголосовать: нравится +3 Проголосовать: не нравится

    Really? Turing state machine, second year of CS university. Yes, the actual problem is quite funny, but I cannot really call it so brilliant.

    • 15 лет назад, скрыть # ^ |
       
      Проголосовать: нравится +10 Проголосовать: не нравится
      Can you fit it into 30 instructions and 150000 steps for N=5000?
      • 15 лет назад, скрыть # ^ |
        ← Rev. 2  
        Проголосовать: нравится 0 Проголосовать: не нравится

        Yes.
        For small test one just need to write down the N in binary on the tape (it takes 9 instructions), and iteratively substract 1 from this number, and move the flag one cell to the right.
        For large test it takes slightly more instructions than allowed (because of hard-coden writing of N), so we can just increase the base of numeral system :)
        Number of steps is O(N logb N), where b is the chosen base (5 is enough).

        P.S. It took me 10-15 minutes to get with an algo for small test, and after that enhancion for large test was obvious. Really, one cemester of computability theory at the second year of university — and problem is quite straightforward :)
        P.P.S. To be honest, careful implementation of this idea might take a while.
  • 15 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +3 Проголосовать: не нравится
    Yesterday, in the evening, I was intrigued by your description of the problem and decided to look at it. The first part (small input) turned out to be not very hard and I've managed to find the solution within an hour.

    However, the second part was much trickier and I've spent hours trying to solve it and eventually managed to do it and successfully passed the hard test submission. That was fun, and pretty interesting task optimizing the final idea. Thanks for noticing this problem :)
  • 15 лет назад, скрыть # ^ |
    ← Rev. 2  
    Проголосовать: нравится 0 Проголосовать: не нравится

    I like the concept of the problem, but dislike the process of solving it=)

    For anyone familiar with Turing machines the solution with O(NlogN) runtime and (log2(N) + C) program size should be obvious. I spent a lot of time optimizing the constant C to fit 30 commands limit.

    The final submission contained: writing the binary number (13cmd), left-pass with decrease (7cmd) and right-pass with move (8cmd) with total of 28cmd for large output.

    It's quite interesting what is the minimal number of commands required for large output. Also I don't understand how increasing the alphabet size can help in optimizing the program, since a lot of states must be sensitive to all the possible chars.

    • 15 лет назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится
      Can you describe how you've managed to fit left-pass descrease and right-pass move into 7 and 8 commands? What are the states?
      • 15 лет назад, скрыть # ^ |
        ← Rev. 3  
        Проголосовать: нравится 0 Проголосовать: не нравится

        First of all, higher bits of the number should be placed to the left. Otherwise you won't be able to easily decrement in left-pass. So left-pass decrement is iterating over digits from lower-valued to higher-valued.

        For decrement, there are two working states. The difference is: whether we have to decrement the rest of the number or not. For these two working states we have to write commands for all possible input chars (empty/0/1), so we get 6 commands. Also we need one special state and one command to step left from initial(empty) position to the first digit of number. When the decrementing robot steps on the empty slot, it either drops the cake (if still wants to dec) or simply steps to the right (if does not want to dec).

        For right-shifting the number, there are also two working states. The difference is: whether the previous digit was 0 or 1. Of course we have to react to all possible chars (empty/0/1), so we require 6 commands for these working states. However, we need one special state and two commands to handle the first digit properly, because previous digit for the first digit is "empty".

        So for each of the decrement and move passes there are three states, one of them is "starting state" and the other two are "working states". And of course there are other 13 states+commands for initialization.

        • 15 лет назад, скрыть # ^ |
           
          Проголосовать: нравится 0 Проголосовать: не нравится
          In my solution most significant digits are at the right side. However, I'm using base 5 instead of base two.
        • 15 лет назад, скрыть # ^ |
           
          Проголосовать: нравится 0 Проголосовать: не нравится
          Thanks, now I understand and it is quite straightforward, when I'm looking at it like that :)

          I, myself, while solving this task and thinking over the optimization of the "moving" idea (I've failed to compress it good enough for the large input), came up with the combined approach of flagging and moving at the same time. Now I can do n=0..8 in 1..9 instructions and for n > 8 in 26  instructions. This was the solution that passed tests for large input. 

          And, actually, I'm using ternary system - for my particular approach this seems to be the best choice (8 digits instead of 13 for binary), since I have only one state that reacts to digits 1 and 2 (all other states don't need to work with these digits). 
    • 15 лет назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится
      I still don't get how can one achieve N log N runtime. Whatever way of solving this problem I come up with, it requires at least N^2 of operations.
      Can someone elaborate more on the way to improve runtime?

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

        Store N-13 in first 13 cells (base 2 is enough here), least significant bit to the right.

        Each step now consists of:
        - subtracting 1 - takes one pass from right to left and 2 states (whether we still have to subtract)
        - shifting the entire counter 1 cell to the right - takes one pass from left to right and 3 states (carrying empty/zero/one)

        If we have to subtract from empty cell on the left edge, that means we've finished, so do final pass to the right (1 special state) and halt.

        Total runtime is approx. 2 * N * logN, which is about 130000 with N=5000.

        I squeezed it into 29 rules (not much optimization was really needed) and it passed in practice.

        UPD: final pass is actually not needed if we encode N+1 instead of N-13 (and halt at left edge), that fits in 27 rules.
15 лет назад, скрыть # |
 
Проголосовать: нравится +17 Проголосовать: не нравится
"...and the winner of Code Jam 2011 and the title of Code Jam Champion goes to JAPAN'S RNG_58!"
15 лет назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится
Вести с фронта, сообщил Артем Рахов: "У всех все прошло. Упала только B у мерета."
15 лет назад, скрыть # |
 
Проголосовать: нравится +15 Проголосовать: не нравится
Открыли результаты на сайте. Ваня, поздравляю с отличным выступлением!
15 лет назад, скрыть # |
 
Проголосовать: нравится +25 Проголосовать: не нравится
Иван, Артём: жжоте!!!!!
15 лет назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится
А планируется ли разбор задач этого финала?
15 лет назад, скрыть # |
 
Проголосовать: нравится +19 Проголосовать: не нравится

GCJ 2012 will be held in Paris, as it was said on the awards ceremony.

15 лет назад, скрыть # |
 
Проголосовать: нравится +7 Проголосовать: не нравится
hey Rad, congrats for your great performance in GCJ 2011!!!
15 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +45 Проголосовать: не нравится


In rng_58's submission for problem A, he computes the modular inverse for all i modulo MOD:

inv[1] = 1;
    for(i=2;i<MOD;i++) inv[i] = (MOD - MOD/i) * inv[(int)(MOD%i)] % MOD;
   

How do justify this algorithm?  Thanks in advance!
15 лет назад, скрыть # |
← Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

For problem B, "Rains Over Atlantis", there is a very nice algorithm by g201513.
The complexity is O((RC)^2).

The idea is to modify the map, by increasing some fields, without changing the
result:

1)  If the height of each field is increased up to the nearest multiple of M,
        the result is unchanged.

With that property, each erosion decreases heights by either 0 or M.
We can rescale the map by dividing everything by M, and assume from now on that
M=1.

2)  If a field needs d days to reach the level 0, then it's as if its
         height is d.

3) If each field with positive height has a lower neighbour, then the result is
     the maximum height over the map.