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

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

Автор Bojack, история, 6 лет назад, По-английски

Let's discuss the problems.

Problem Set

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

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

How to solve C, D, H, J.

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

    If this contest has a time limit, Problem C is very interesting

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

    Is there any time limit?

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

    Problem C
    Let x be the number which has odd number of odd divisors​. Through observation, you can find that , where ei is even. In this configuration, total number of odd divisors will be . In other words, we are looking for x = 2w × y, where y is a perfect square number.

    You should solve the problem for range [1, N], and print solution of range [1, R] minus solution of range [1, L - 1]. To solve for [1, N], you should iterate for all possible power of 2. For each k, add .

    Problem D
    Firstly design a function f(n), which returns the highest number which is smaller than n, and has the digits allowed in the problem statement. This can be easily done with greedy observations.

    You can now start with input N, and iterate by setting N = f(N) each time. Stop this iteration and print the answer, when current N is prime. Use Miller-Rabin for primality testing. I don't know the proof why a prime number with the given definition can be found with small number of iterations. We went with intuition. If anyone can prove it, then please share it here.

    Problem H
    Trivial dynamic programming solution. States: idx, lastColor.

    Problem J
    You can always make the longest possible path in the answer graph equal to 1. Make the tree rooted. Toggle the direction of edges in consecutive levels to face different directions. Let's say u - v be an edge, where u is at level i. Set the direction of the edge from u to v. Now, let v - w be an edge, where v is at (i + 1)th level, Here set the direction from w to v.

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

Where I can submit?

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

What about problem D?

Our team got AC on problem C in a O(1) solution.

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

    Check prophet_ov_darkness's comment.

    What is the O(1) solution for C?

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

      The numbers to count have even power of odd primes. They can or can't have even power of even prime, 2. So, the number of numbers those are either square or double of a square counts. But precision is an issue that was to be solved.

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

        How did you solve the precision error?

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

          We got Wrong Answer for precision error while calculating square root of a number. So instead my teammate did binary search to calculate square root.

          Also you can use sqrt((double) value); This is called typecasting. Really important issue.

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

how to approach the problem I (Vugol search)????

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

    We solved it using trie.

    For any query, note that we can do any of the following.

    • Find an anagram fron the database and try to maximize lcp+smartness
    • Ignore the anagram thingies and just try to maximize lcp

    For the latter, keep a trie using all the words from the database. Now traverse for the query word and take the maximum lcp.

    For the first part, find out which strings in database are anagrams of each other. You can partition them into components by simply sorting the characters of those strings. Now for each such component i.e. the strings which are anagrams of each other, make a trie consisting of the database words. Find out which query words are anagrams of these strings. Traverse the trie and try to maximize the results by a rmq-similar approach.

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

      How to solve E?

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

      can u briefly explain the approach of finding anagrams from the trie plz?

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

        We can internally sort the strings. Like "me" becomes "em". Now the strings with the same sorted outcome are anagrams of each other. Build a trie using those strings. Similarly find out which query strings have the same sorted outcome i.e. anagrams of these strings. For those queries, traverse the trie and update the maximum value if possible.

        I tried to draw something: (Not exactly sure if it helps. I am bad at explaining things, I guess.)

        ( If the image doesn't show: https://pasteboard.co/HHl76cI.jpg )

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

      How did you solve F (find the substrings)?

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

        We calculated the number of distinct sub-strings for every length upto |s| using suffix array. Then it got pretty easy. We had d_i as the number of distinct substrings of length i, the result is summation of (26^i — d_i) for every i from n to m. mochow did it. :3

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

does anyone have the problem set of onsite dhaka regional?