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

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

Hello Codeforces,

I invite you all to participate in HackerEarth's April Easy on the 2nd of April at 9:30 PM IST.

You will be given 6 problems to solve in 3 hours. The problem difficulty will be similar to that of a Div. 2 round on Codeforces. Each problem will be worth 100 points, but partial scoring is allowed so you can try to pass as many tests as you can.

The contest will be rated and will have prizes for the top 5 beginners.

The problems have been set by Pranet Verma (pranet) and tested by me (akulsareen). I would also like to thank HackerEarth admin, Arjit Srivastava (belowthebelt) for all his help.

Good Luck and Have Fun.

EDIT: Contest has been postponed by 1 day to avoid clashing with the Codeforces round.

UPD: Contest has ended. Congratulations to the top 5:

  1. azukun

  2. ceilks

  3. Kmcode

  4. hellman_

  5. rantd

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

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

EDIT: Contest has been postponed by 1 day to avoid clashing with the Codeforces round.

Now it overlaps with COCI.

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

I read the tags! :P

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

Reminder: Contest starts in a couple of minutes. Do take part.

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

Great Problems,thanks for your effort, problems could had been less ambiguous

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

How to solve linear recurrences?Mine was O(6^3*logn) which obviously din't pass.

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

    I had 5x5 matrix M which mapped (F[n - 2], F[n - 1], G[n - 2], G[n - 1], T[n - 1]) to (F[n - 1], F[n], G[n - 1], G[n], T[n]) where T[n] = H[0] + H[1] + .... Also precomputed all powers of the matrix Me for e = 0, ..., 215 - 1 and for e = 215, 2 * 215, 3 * 215, ...215 * 215. Then each query can be done with multiplication of two matrices (one from the first set and one from the second). But still I had to optimize to fit in 2 seconds TL.

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

      If you pre-compute M1, M2, M4, ... , M230, then you can compute the answer to each query in approximately 5^2*log(n) operations. To achieve this reduction perform the multiplication from right to left. Refer to the editorial for more details.

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

        speaking about editorials, where are they actually?

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

          If you are looking at the problem page then there are 3 options, "Problem", "editorial", and "my submissions".

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

            I have there only Problem and My submissions, but no Editorial :(

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

              Editorial.

              Also, if you are getting the option to go to practice area, do that and then see if you get any editorial option. If even that does not work then contact HackerEarth admins for help.

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

        I precomputed M1, M2, M3, ..., M215 and M215, M2·215, M3·215, ..., M215·215. So that I can compute Me = Ma + 215·b = Ma·Mb·215 in only one matrix multiplication.

        So I wonder what was so unoptimal in my solution, such that even log(n) multiplications from your solution may pass.

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

          You seem to be answering each query in O(m^3) (Please correct me if I'm wrong). Intended is O(m^2*log(m)) per query.

          My bad. Yours is indeed faster in theory( 5 vs log2(1000000000) ). However, your solution does seem to be suffering from cache misses(just changing the order of the loops in matrix mul achieves a small speedup).

          Dude! Use scanf and printf!. Your solution gets AC well within time limit(0.9s)

          http://ideone.com/anJgcj

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

            Ahh right, thank you very much for the investigation! My PR() macro confused me.

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

      Is it too much to ask you what was your matrix M? I tried the same thing but I couldn't even pass the sample tests.

      PS: Just found editorial is available, sorry for comment

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

        Sure, here it is:

            int step[5][5] = {
            //  F-2 F-1 G-2 G-1 T-1
               {0,  1,  0,  0,  0}, // F-1
               {0,  A,  B,  0,  0}, // F-0
               {0,  0,  0,  1,  0}, // G-1
               {D,  0,  0,  C,  0}, // G-0
              {FD, EA, EB, FC,  1}, // T-0
            };
        
»
8 лет назад, # |
  Проголосовать: нравится +13 Проголосовать: не нравится

How to solve A?

  • »
    »
    8 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится
    int n;
      cin >> n;
      vector<ll> a(n);
      rep(i, n) cin >> a[i];
      SORT(a);
      ll ans = 0;
      for (int i = 0, v = 1; i < n; ++v) {
        ll c = v * 1ll * v;
        if (c >= a[i]) {
          ans += c - a[i];
          ++i;
        } else {
          ans += c;
        }
      }
    
      cout << ans << endl;
    
    • »
      »
      »
      8 лет назад, # ^ |
      Rev. 2   Проголосовать: нравится +20 Проголосовать: не нравится

      It doesnt work, actually.. Test:

      2
      4 10
      

      UPD: But is gets 100 on Oj...

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

        You did not read statement carefully:

        "You quickly gather the balls and try to reconstruct a square pyramid(maybe of a different height) by using ALL the recovered balls"

        You have to use all found balls. E.g. in your example the optimal solution is to buy 1, for first colour, then 0 for second (you have 4 already), 9 for third (you have 10 balls, but according to statement we have to use ALL balls, so we can't throw one extra ball away), and we heed to buy 6 balls for the last color (16 — 10 that we have = 6). so, all together we need to buy 1 + 9 + 6 = 16 balls.

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

          Im using all the recovered balls, man:

          Lets split 10 into 1 + 9 and now we can build a square pyramid with height = 3.

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

            You cannot split them as each layer has to be coloured differently. The 10 balls are of the same color

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

            you can't split balls into two or more groups, because then you will have at least two layers of same colour which is prohibited.

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

Did you like any problem a lot? Did you dislike any problem a lot? Did you enjoy the problem non-linear recurrence? Do you have any other issue/praise for the contest? All feedback is welcome.

Also, editorials for all problems should be available.

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

Easy Non Linear Recurrences — I'm fooled :(