Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

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

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

Tomorow , 11 april TCO 2015 Round1A will take place ,

http://tco15.topcoder.com/algorithm/schedule/

time-date :

http://www.timeanddate.com/worldclock/fixedtime.html?msg=TCO15+Algorithm+Round+1A&iso=20150411T12&p1=98

good luck to all the participants !!!

ps : how do i register to it ? its the same like any regular srm?

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

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

Yes, it runs exactly like an SRM. It's still a match, just not a single-round one :D

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

codeforces is unnecessary

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

    You know what is unnecessary? Spam comments. (as in: comments that are unrelated to the topic of the blog post)

    When spam appears, downvotes are necessary.

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

Does anyone know how exactly byes work this year? If I am among 250 top rated members, does it mean that I automatically advance to round 2 and I cannot take part in Round 1A?

If yes, will there be any parallel round?

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

Can Division 2 competitors in TopCoder register for TCO 15?

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

По всей видимости, я очень долго не заходил туда. Контесты теперь не проводятся в java-плагине? UPD. Разобрался, просто случайно зашел в arena beta.

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

rated?

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

I'm new to Topcoder. So, can anybody tell, how to hack here (is it similar to Codeforces)

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

I can't register. It said registration was by invitation only. Did anyone meet the same problem?

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

Does anyone have problems with opening web-site (http://topcoder.com/tc) or arena? I can't enter. Thanks.

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

как решать B?

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

    Применили указанную операцию К раз при помощи бинарного возведения в степень. Посмотрели, что во что перешло: клетки разбились на классы эквивалентных. Ответ — произведение (размер_класса_i + 1).

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

      Можно без бинарного возведения в степень, K = min(K, 60) достаточно.

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

        так а почему можно останавливаться после 60 ходов... там же как бы цикл... или я как-то не ту задачу умудрился сдать?

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

          За 60 ходов все, кто могли, успеют встретиться, т.к. они уже точно попадут в цикл

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

            а, ну и вы смотрите есть ли пересечение по вершине на пути, ок.

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

    Заметим, что если какие-то два токена оказались в одной позиции, то сколько бы раундов мы не делали, они будут все время находиться на одной позиции. Для каждой стартовой позиции токена промоделируем min(100, K) раундов и запомним, в какой клетке остановился токен. Если на какой-то клетке в итоге остановилось несколько токенов, значит изначально (чтобы не проиграть) мы могли выбрать только один из них (или ни одного). Соответственно, для всех конечных позиций перемножим количество остановившихся на них токенов + 1.

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

      спасибо, почти так же думал, только не подметил, что после первой встречи токены уже будут всегда вместе и морочил себе голову включениями/исключениями))

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

broadcast after the round:

Any positive score advances to round 2. Congratulations to all advancers!

lol ... even easier than gcj prelims. (I only solved 250. I don't feel that I should advance).

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

What is the solution for 1000?

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

    Hall's theorem. Then just check every subset of one side of the graph.

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

      So, the best overall way of how I could have solved it is by typing "bipartite graph perfect matching conditions" into Google. Hall's theorem comes up a lot on the first page.

      I guess that's an important skill too: intuition about when to go to the library.

      I converted the problem into something to do with the structural rank of the nxn matrix, then got stuck in that idea and fell asleep.

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

        Yyyyy, man, Hall's theorem is the first thing one should learn after getting know what a "matching" is. It is absolutely basic theorem when dealing with matching and you dare to say that main difficulty was to google it >_>...

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

          Judging by the voting pattern, my guess is you have 7 socks.

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

          I think many people learn new stuff when they see a problem that uses it. I've probably solved more than hundred matching / flow problems but this is the first one that I used Hall's theorem, so I don't find this surprising at all..

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

    Another keyword is a constricted set.

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

Any cool solutions for the first problem with bigger constraints?

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

    If the range is long enough (10^10 is plenty), the answer is 10. Otherwise use brute force. This is an O(1) solution for the general case. Does that count as "cool"? :)

    Oh okay, 10^20 is a lot. Instead you can construct all reachable sets of digits like this: go from the left to the right, remember the set of digits you already used, and whether you match the prefix of L so far, the prefix of R so far, or are already somewhere inbetween. (In the first two cases the set of digits you can use next is restricted.) Then do the less-brute force step in (2^10)^2 to find the best solution. (Disclaimer: I haven't tried actually implementing it.)

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

      I've implemented your second approach during the contest, but with brute force instead of DP, but the idea is clear here. But DP doesn't seem to be cool :p

      If the range is long enough (10^10 is plenty), the answer is 10. Otherwise use brute force.

      What do you call "brute force" here? Is it fast enough? I am looking for solution which would work for some giant constraints, arbitrary numeral system, etc.

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

        You kind of missed my first point. What I tried to say is that this problem is cool because all large instances are actually very easy, and you have to solve only the small ones. That is an unusual property.

        If you skip that optimization and always run the solution I sketched in the second paragraph, its time complexity will be O(n2^b + 4^b), if L and R are n-digit numbers and we are solving the problem in base b. In particular, this is fast enough for huge numbers and base 10.

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

          Actually you can do second part in O(2b * b) -- just push numbers to all submasks cutting bit by bit.

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

    cannot prove it, but my thought is like this:

    for each bitmask 0 ... 2^10-1 (representing digits) find the smallest number in [L, R] that has the corresponding digits. find next number with those digits (and that is not next_permutation) and check if it is in [L, R].

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

BTW, on 250, this solution also passed:

For each i in [L,R] and each j in [i+1,i+1000], ans = max(ans,shared_digits(i,j))

Even replacing 1000 with 100 still passes :P

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

    Why 100, I tried with 9 in the contest. The logic was to swap last two digits and get all the matched characters. There are many flaws in that. Can you prove why 100 is sufficient?

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

      Sorry, I cannot prove it. The main idea reason I thought it would work is for swapping the last two digits as you said (and catching a couple other things). 9 is only sufficient for swapping the last two digits if those digits are 45->54 though, like 37-73 requires a lot more.

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

Hey, can someone explain how the 250 point problem has to be done?

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

    Here is my idea (passed)

    first , given two numbers how can i find their similarity?

    Assign to both number a list of 10 bits , (bit number i is one if the digit appears at least once in the given number otherwise its 0) ;

    One can see that this list can be stored using an integer <2^10 using binary representation;

    Now you just iterate from L to R and for each number you brute-force (using backtracking) any combination of its digits (one number can have at most 5 digits) and then you check whether the resulting bit-mask has appeared before in some past value.

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

How to solve 500?

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

    Notice that if two tokens are ever on the same square, they will continue to be on the same square for the remaining turns, so a sufficient and necessary condition for two tokens to be on different squares after any of 1, 2, ..., K turns is for them to be on different squares after K turns.

    Then, find, for each square s, where a token on that square would be after K turns. Call this square out(s). For a set a1, a2, ..., ai of squares such that out(ai) = s for all i, at most one of them can have a token, so multiply the final answer by i + 1. Do this for all s to finish.

    One implementation detail is to find out(s) without doing a dfs of depth K ≤ 109. You can note that there must be a cycle after at most N turns. From here, either do something like K = min(K, N + 1) or do cycle detection (keep track of last_visited for each square).

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

      Thanks!!

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

      The last part can also be solved using the same principle for finding the lca of a tree. Pre calculate the distance between every power of 2 up to 2 ^ 30 and for each token its final position can be calculated in O(logN).