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

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

Hello Codeforces,

I would like to invite you all to participate in the 2017 JUST Programming Contest 4.0 of Jordan University of Science and Technology. The contest was originally held on 16th of September , and it will launch in Codeforces Gym tomorrow Saturday 23 September 2017 14:30 UTC.

The problems were prepared by justHusam (Husam Musleh) and Vendetta. (Ibraheem Tuffaha).

Thanks to I-Love-Islam (Rami Sadaka) and The-Legend (Abdulmajeed Alzoubi) for sharing the ideas of two problems.

The duration of the contest is 4 hours, and the registration will be open 6 hours before the start of the contest.

Good luck for everyone, and I wish you all Accepted solutions.

Note: Don't forget to use fast I/O methods.

UPD: Registration is currently open.

UPD: The contest will start in 30 minutes.

UPD: Tutorial

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

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

Should it be done in team or individually?

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

    The onsite contest was made for teams of no more than Experts level, so a Candidate Master is preferred to participate alone.

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

Is "Scanner sc = new Scanner (new File (PATH))" considered as a fast I|O method in java ?

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

    No. You need to use BufferedReader / PrintWriter instead of Scanner / System.out

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

How to solve A?

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

    Hint: Consider bits one by one.

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

    Sorry for the latency, you can check the editorial: http://codeforces.com/blog/entry/54840

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

Could you share F's tests, or it's generator please?

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

Can someone explain the solution for F ?

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

    You can calculate the number of palindromic substrings for each string, and map strings, to their index. After that you reduced the problem to a max range query.

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

      We calculated the no of palindromic substrings in O(30*30) time. Is it expected one ?

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

        Yes, it runs fine, in case my solution passed in 1746 ms.

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

          Can you share your solution please :)

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

            https://ideone.com/U1GmWp
            It's basically what bazsi700 explained, I counted the value of palindromes for every string, mapped the strings with a trie and used a sparse table to do the queries

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

              Could you please tell me why I'm getting TLE on test 2 with this code? https://ideone.com/4TrlFW

              I wrote I/O as you did to be sure it wasn't that.

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

                Well, it's better to use sparse table and unordered_map in your code, but you would receive wrong answer because what calculate the length of a C string is strlen, since you are using sizeof, it's the same as to add the same thing for all values of strings. And you have to treat the case when l > r.

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

                  Yes I noticed the case when l>r, and I didn't know about strlen, thank you very much. But the TLE is because of the segmentTree factor which is a little bit worse than sparse_table?

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

                  Probably yes, try to optimize the query in the range and how you find the index of some string, I used a trie for example.

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

        That only means O(104 * 30 * 30) ≈ O(107). If you are getting TLE, then other part of your code is too slow. You must use fast IO.

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

    Sorry for the latency, you can check the editorial: http://codeforces.com/blog/entry/54840

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

Can someone give a hint on E?

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

    Meet in the Middle

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

    Think about divide and after join

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

    Sorry for the latency, you can check the editorial: http://codeforces.com/blog/entry/54840