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

Автор Ahmed_Hosssam, 23 месяца назад, По-английски
عيد سعيد(Happy Eid), Codeforces!

I'm glad to invite you to Codeforces Round 788 (Div. 2), which will be held on May/06/2022 17:35 (Moscow time).

This round is rated for the participants with rating lower than 2100.

You will be given 6 problems and 2 hours to solve them. All problems were prepared by me, Hemose and ZerooCool.

I would like to thank:

The statements are short and we have tried to make the pretests strong. I encourage you to read all the problems.

For people who don't like stories, you will find all the stories written in italic you can skip them safely.

We are sincerely looking forward to your participation. We hope everyone will enjoy it.

Good luck and see you in the standings!

UPD: The score distribution is 500-1000-1750-2250-2750-3000.

UPD: We hope you liked the problems, here is the Editorial

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

»
23 месяца назад, # |
  Проголосовать: нравится +76 Проголосовать: не нравится

GUC gang!

»
23 месяца назад, # |
  Проголосовать: нравится +108 Проголосовать: не нравится

As a tester, I'd like to say that no java coders were hurt in the making of this contest.

»
23 месяца назад, # |
  Проголосовать: нравится +150 Проголосовать: не нравится
»
23 месяца назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

As a possible contestant if time permits, I would like to present my sincerest congratulations and best wishes to the GUC team for the kind endeavors.

Heartbeat

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

This is the first Egyptian round after a long time! Our congratulations!

»
23 месяца назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

Eid ul Fitr Mubarak to you and your family.

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

Score distribution? (:

»
23 месяца назад, # |
Rev. 2   Проголосовать: нравится +14 Проголосовать: не нравится

As a GUCian, I'd like to say that those people are wonderful. Hope it will be a nice contest!

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

EID Mubarak

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

Eid Mubarak

»
23 месяца назад, # |
  Проголосовать: нравится +2 Проголосовать: не нравится

distribution?

»
23 месяца назад, # |
  Проголосовать: нравится +2 Проголосовать: не нравится

Egyptian round? Long time no see)

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

Hemose is back yayy! :D

»
23 месяца назад, # |
Rev. 2   Проголосовать: нравится +39 Проголосовать: не нравится
»
23 месяца назад, # |
  Проголосовать: нравится +10 Проголосовать: не нравится

Looking forward to participate! Eid Mubarak

»
23 месяца назад, # |
Rev. 2   Проголосовать: нравится +24 Проголосовать: не нравится

Coders(>1600 rated) : Finally we can participate ;-;

»
23 месяца назад, # |
  Проголосовать: нравится +30 Проголосовать: не нравится
As a GUCIAN tester, I am proud of you and your great round.
»
23 месяца назад, # |
  Проголосовать: нравится +9 Проголосовать: не нравится

"You cannot vote twice. You have already voted for this topic before."x10

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

We're so proud of u guys. Keep going and make us proud in ICPC too , ISA

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

GUC on fire

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

Maybe Egyptian round is full of Bitwise and Math problem hahaha :)

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

It's my first time to participate the div 2 contest unofficially.

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

EID Mubarak

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

As this is an egyptian round, being the egyptian king I must perform great in this round. Hoping for good fat +ve delta.

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

3id s3id!

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

i hope be pupil in this round

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

    why you practice so many problems,but still newbi?

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

      Because in a long period in my training I was solving easy problems and I did not benefit from them, and another reason was that I had to solve problems from training beginners in order to help them solve them because I am mentor

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

        wow, I really hope you could be more and more exctllent! As for me, I just learn algorithm for three months, ans I hope I can be a master one day! Best wishes for you!

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

how cool man

»
23 месяца назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

Eid Mubarak(⦁ᴗ⦁)

»
23 месяца назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

As an Arab contestant, I am always glad to see Egyptian rounds on CodeForces. Well done GUC, keep it up guys!

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

Good luck everyone

»
23 месяца назад, # |
  Проголосовать: нравится +10 Проголосовать: не нравится

"For people who don't like stories, you will find all the stories written in italic you can skip them safely." — Whoa cool!

»
23 месяца назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

Good luck everyone!

»
23 месяца назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

Wish you all a great rating gain.

»
23 месяца назад, # |
  Проголосовать: нравится +2 Проголосовать: не нравится

Eid Mubarak to everyone

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

I enjoy problem E but I hate problem D!

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

    n lines would make these many triangles = 2 * (n)^2 / 3

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

      what is the the proof?

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

      I did it like this :- we can have 3 directions for lines to draw ,each time we draw a line in one direction then it intersects all the lines in other two direction and thus creates 2*X more equilateral triangle where X is the total number of lines in other two directions.

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

Does GNU C++17 7.3.0 allow __int128? I met this compilation error:

Can't compile file:
program.cpp: In function 'int main()':
program.cpp:266:17: error: template argument 1 is invalid
  vector<__int128> limit(60, 0);
»
23 месяца назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

Dang, I think I was really close to solving E for the first time. It's a pity I now have to wait for system test to end in order to test my solution :(

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

Problem C was a modification of 1534C - Little Alawn's Puzzle

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

I just don't know why D had so tight constraints and the fact that I used some random optimization was able to pass the pretest is insane.

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

In E we can choose any vertex to be root, right? And max xor will always be n, where n is number of vertices?

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

I really enjoyed this round, thx to everyone who participated to make this contest! :)

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

Was F digit dp?

»
23 месяца назад, # |
  Проголосовать: нравится +43 Проголосовать: не нравится

In my opinion, I think problem D is more like a math puzzle than a cp problem.

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

    In programming contest ICPC style are many full math problems, with many theorems, it's a good way to train for it. However, I think it's more an Ad Hoc problem than a full math problem. And you need binary search too

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

No idea with Problem E & F after solving A~D in ~1h :(

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

    E is also a math puzzle, like D :)

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

      I solved a similar problem which asked how many area can be divided by $$$n$$$ lines in a infinite plane before. So I came up with that idea for D immediately. But no clue for E hh, maybe need more practice.

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

        We can't avoid the Nth bit appear in the final cost. So the answer of maximum cost is 1 << N. assign this number to root node. Then for any other node x, if its depth is even (depth of root is 0), assign x and x | (1 << N) to it and the path linking it to its parent node, otherwise assign x | (1 << N) and x.

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

          that logic is so clear..! I didn't even figure out the root can be fixed as 1 << N.. thanks for given clue..!

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

        Can you tell me how to solve the problem you mentioned in the comments(How many area can be divided by n lines in a infinite plane)?

        I was recently asked this question in an interview. I was not able to give optimal solution. Please help me out.

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

I have only a few words to say about this: damn it i cant attach pictures

link

Although E and F were very nice

»
23 месяца назад, # |
  Проголосовать: нравится +12 Проголосовать: не нравится

Q4 is Guessforces

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

A simple testcase could hack my solution of B, and I was so anxious that my analysis of the time complexity is wrong :(

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

my python code for Q4 was giving TLE but it was only O(1). Can someone tell me what’s the problem?

»
23 месяца назад, # |
  Проголосовать: нравится +17 Проголосовать: не нравится

Thanks for the strong pretests!!

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

Glad that you provided so many samples in the questions...

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

    Seriously bro? Look at question (Edit: C), I took wrong modulo and got wrong answer on Test 2 and was going to leave contest. In such problems, it better to give atleast 1 case where number is larger than the modulo

»
23 месяца назад, # |
Rev. 92   Проголосовать: нравится +16 Проголосовать: не нравится

Deleted

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

    what is the trick behind D, it got decent submissions! I couldn't find any pattern.

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

      Every new line creates two triangles with each existing line.

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

        just a clean drawing on a paper can help me lead to the solution?

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

          There are three types of line depending on the orientation of the line, so let the number of each be x, y, z. The total number of triangles created by those lines is equal to $$$2(xy + yz + zx)$$$ which has to be greater or equal to n. To minimize the sum x + y + z, the difference between x, y, z has to be minimized (I think you can prove it via fixing one of the values), so the triplet should be in a form of (x, x, x), (x, x, x-1), or (x, x-1, x-1). Hope this makes sense

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

            sum i.e (a + b + c) would yield maximum value only when their absolute difference is minimum right i.e just do (a + b + c)/3 and distribute the remainders among them!

            But how I would reach the conclusion that our total number of triangles is 2(a*b + b*c + c*a)? Can you give me some thinking approach?

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

              Consider the intersections of these three types of lines. It is easy to see that if two lines are of different types, they will intersect as they are not parallel, and also each intersection of two lines creates two triangles. Now you might wonder what would happen if three lines intersect at the same hexagon. You can consider it as three separate intersections that each contribute two triangles, making in total 6 triangles, so we can count the number triangles as two times the number of pairs of lines that are from different types, thus, $$$2(xy + yz + zx)$$$.

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

          Well I used the given image and Paint. That works too.

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

    If you think "A problem has too many details", then you may solve it in a wrong way.

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

      Deleted

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

        I said "One" not "The first".

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

          Oh Okay, I meant details in the statement not in the solution.

          My opinion is "B" and "A" problems should have little details in the statement and be simple. For example the easy problems in "ARC" has difficulty like div2A,B but they're simple in their statement.

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

      He has a point. The statement is way too long and can be simplifed. The entire part about special characters is useless and can be replaced by giving input as a binary string instead.

      Probably shorter way to write the statement
  • »
    »
    23 месяца назад, # ^ |
      Проголосовать: нравится +23 Проголосовать: не нравится

    E surely doesn't have much details.

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

      It has details in the statement, I mean many things got mixed together and then we have this problem.

      For example, nodes have weight and edges also have weights, A path can start at a node and ends at an edge and also it can end at a node.

      I'm not against that type of problems but I just like the problems to be more natural.

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

    +1 to every point

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

    Is the technique used for solving F pretty well known? I couldn't get the part where they are generating bits and maintaining a difference as they go over each bit position. Can someone explain what they (almost all solvers?) are trying to do?

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

    Mr_Solution If C is a bit standard problem, Where can I find/practice those types of problems?

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

They should have kept round 786 on Eid ;)

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

What an amazing Round Thank you to all the Problem Setters and Testers

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

In problem D, I figure out that drawing lines gives you {+0, +2, +4, +4, +6, +8, +8, +10, +12, +12, +14, ...} more equilateral triangles. With this pattern, it is easy to binary search the minimum number of lines needed to make at least n equilateral triangles.

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

    ohh noice ! i have a differnt approach for D!! as we can see there are only 3 differnt slopes of the lines possible and any two lines with different slopes will intersect for sure hence every two lines with different slopes will intersect and will give rise to 2 equilateral triangles ,now its not dificult to see that if i have x lines then i should make lines with differnt slopes in such a way that differnce between there fequency is as small as possible to maximize the intersections and thus triangles ... with this i moved forward , precomputed all the required values and then its just lower_bound!

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

    oeis may help you

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

my python code for Q4 was giving TLE but it was only O(1). Can someone tell me what’s the problem?

»
23 месяца назад, # |
Rev. 2   Проголосовать: нравится +10 Проголосовать: не нравится

156110044 is it anti-anti-cheat approach? :D

»
23 месяца назад, # |
Rev. 2   Проголосовать: нравится +43 Проголосовать: не нравится

Earlier I noticed just how many people got TLE on problem B at test 29.

Turns out that test 29 was actually my test...

Sorry guys :(

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

what is the logic for problem A ?

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

Just realized that I got WA in problem C cause i forgot to mod the answer by 10^9+7 :')

»
23 месяца назад, # |
  Проголосовать: нравится +73 Проголосовать: не нравится

To not keep you waiting, the ratings are updated preliminarily. In a few days, I will remove cheaters and update the ratings again!

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

I'm curious what is the rejected problem is. Maybe revealing it after this contest end is nice.

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

Hi, I have been accused of cheating on problem B of this round. It doesn't make any sense because it was a trivial solution. I do see that the people mentioned do have similar solutions (one of them has even contacted me a few minutes back), but since it's just one line of code that gives the solution and the chance of that being similar is fairly high. Is there anything I could do to reverse this? There are no "pre-published" resources, but I request you to take a look this verdict once again.

Thanks.