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

Автор SlavicG, 23 месяца назад, По-английски

Hello Codeforces!

mesanu, flamestorm, MikeMirzayanov and I are glad to invite you to Codeforces Round 827 (Div. 4)! It starts on Oct/13/2022 17:35 (Moscow time).

The format of the event will be identical to Div. 3 rounds:

  • 5-8 tasks;
  • ICPC rules with a penalty of 10 minutes for an incorrect submission;
  • 12-hour phase of open hacks after the end of the round (hacks do not give additional points)
  • after the end of the open hacking phase, all solutions will be tested on the updated set of tests, and the ratings recalculated
  • by default, only "trusted" participants are shown in the results table (but the rating will be recalculated for all with initial ratings less than 1400 or you are an unrated participant/newcomer).

We urge participants whose rating is 1400+ not to register new accounts for the purpose of narcissism but to take part unofficially. Please do not spoil the contest for the official participants.

Only trusted participants of the fourth division will be included in the official standings table. This is a forced measure for combating unsporting behavior. To qualify as a trusted participant of the fourth division, you must:

  • take part in at least five rated rounds (and solve at least one problem in each of them),
  • do not have a point of 1400 or higher in the rating.

Regardless of whether you are a trusted participant of the fourth division or not, if your rating is less than 1400 (or you are a newcomer/unrated), then the round will be rated for you.

We would like to thank:

We suggest reading all of the problems and hope you will find them interesting!

GLHF!

UPD: Editorial

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

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

As the one, who translated statements, I promise, Timur has legs!

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

I got pinged lol

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

Finally, MY FIRST UNRATED ROUND >:D

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

As a tester, SlavicG orz

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

As a tester, I suggest while(true){ if(time != contest_time) continue; else return write_contest; }

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

    That code uses 100% of CPU Thread, use something like std::this_thread::sleep_for(std::chrono::milliseconds(1)) to avoid that.

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

There were no Div. 4 rounds before. There were times...

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

Love to see haochenkang testing! Gl everyone!

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

As a tester, I'm really happy to be a part of this contest :)

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

waiting for long time...Finally div 4 come ..very exited ...

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

Best Div. 4 round I've tested so far!

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

I hope this is my last rated Div 4 :>

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

As a tester, I just wanna say the G in SlavicG stands for top G.

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

How do you become problem setter, tester, helper or any of such things?

And also do these people get paid or they do it for fun?

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

    setters do get paid, there's a blog in the catalog about that. in the meantime, testers either get contacted from setters directly or from other testers, and don't necessarily get paid.

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

    No, testers do not get paid.

    I like being a div. 4 tester because i can't wait for div 4 problems XD

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

      If you want to prove that you are SlavicG's #1 fan, then you should change to my profile pic to show your loyalty.

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

    Please read this, it's about becoming a problem setter.

    You can become tester if your friend is the author/coordinator/another tester, they'll invite you. Note that authors need to be very careful who to trust, because they don't want to get the problems leaked.

    Also, testers don't get paid unlike authors and coordinators. We do it for free because it's fun :)

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

      I think it's unfair, testers should get paid with at least an autograph from SlavicG himself. You already got plenty of autographs but us the average testers never get to taste an autograph >;((

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

        What an excellent suggestion, I also want autograph from SlavicG! But he didn't invite me this time, so I have no right to claim it unlike you :(

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

          Oooof right, you know what, let's go on a strike if he doesn't invite you next time, or if he doesn't pay us with juicy autographs

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

I can't believe that I have 2 more rating than the maximum to participate in this contest as rated contestant, I wish I had waited a few minutes before submitting the last problem in the previous contest. -_-

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

Specialists Be Like

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

This is harsh. I have used codingblocks.com online compiler and have not copied any text from anywhere and done it on my own. This is just a coincidence and nothing else. https://mirror.codeforces.com/submissions/code_vishal18# https://drive.google.com/file/d/1xTv1xVGfwwAsr0OIcfZEwf4nqu2GZLF9/view?usp=sharing. Please roll back my ratings. This is really frustrating and demotivating.

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

Hi, I'm a Chinese student, my English is bad. So, I want to Make frinends to learning it. After reading the previous words, you can also find that my English is not good. We can also progress on algorithms together. Thanks to you read my words.

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

Some users with rating 1400+ create new accounts and participate in such contests and it affects us low rated users. I hope they stop doing this. This happens in div 2 contests as well.

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

Finally, I can increase my rating :)

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

OmG My FIrsT UNofficIAL ROunD!!!!!!

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

rp++!

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

Good luck to you

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

Hope it won't be queueforces.

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

Very long queue !!

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

I keep seeing "Oops! Codeforces is broken"

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

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

Servers down O_o

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

Div 4 became so popular...

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

stresstestingforces XD

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

As an unrated participant, I really enjoyed the contest. Good job slavicg and team.

Why don't div3/div2 contests have similar problems? :sad:

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

Great contest for a div 4, covered a lot of basic concepts, for the first time I was able to solve the whole set of problems, enjoyed it thoroughly.

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

Imagine submitting a solution and after 30 min long queue getting wrong answer on tc 1.

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

Thank div4 for making me feel less useless, first time full AC without any WA :(

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

I'm so tired for waiting.

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

Deleted.

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

    What's the issue with C++20's gcd function? Let me know so I can mention it next time I cover it on STL in CP

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

    You are invoking undefined behaviour by sorting empty vectors. Gcd is in no way invalid in c++20

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

    I am impressed by how many different explanations there are for why your code is wrong. Check the test case that you failed on. You mistakenly assumed that if the GCD of the entire array is $$$1$$$, then there exists a pair of elements that is coprime. You fixed it by initializing $$$\mathrm{ans}$$$ to $$$-1$$$ instead of $$$0$$$. Everything else was fine.

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

Why was site down all the time! It was frustrating.

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

Is it just me who think that E has way more right submissions that it should have?

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

how to solve G?

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

    Video Solution for G.

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

    Use a mask. Initialize it as the max element in the beginning. Add this to the answer and mark it as used. Then, for each unused element update the element with a new key of (original value with the masked bits cleared). This is the key. The value is a vector of the original values. Use the largest key and sort the vector of the original values. Take the max. Add to answer and mark it as used. Repeat the above until key is 0. Add all unused elements to the answer.

    176046217 I submitted 5 minutes after contest ended.

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

    Let the max element of the array to be the beginning of the sequence, since it has the highest lexicographical order. Then we try to find the element that results in the highest OR value, then update the prefix OR and mark that index as used. At one point where the higher OR value cannot be found, we fill the rest of the sequence with unused elements.

    Since a[i] <= 1e9, which is less than 31 bits, the time complexity is O(N).

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

POV : You missed red and blue being horizontal and vertical specifically

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

Is there any more efficient way to check coprime than generating all in O(1000^2 * log(1000)) time.

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

Problem E Why my solution is giving TLE for test case 4 176003168 176020081 176037934

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

approach for F?

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

    Only two things matter:

    • number of 'a's in the string

    • does the string have any character other than a?

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

    I'd like to expand on tsuu's explanation.

    1) Both strings 's' and 't' contain only the character 'a': Eg: aaa vs aaaa => we can see that the one with lesser frequency wins

    2) String 's' contains many different characters, while string 't' contains 'a' only Eg: aaab vs aaaaaaa => S will never win aaab vs aa => again, S loses

    3) Both 's' and 't' contains many different characters Eg: abcde vs aaazxy => Just pick 'a' as the starting character in S, and any character other than 'a' in t Here we pick a**** vs z***, so S wins

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

      About the 3rd case, both strings are 'a' initially so if string T has different characters, S will win because we can make S starts with 'a' and T starts with anything other than 'a'.

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

https://mirror.codeforces.com/contest/1742/submission/176025562 Why this is not passed any counter exam ple

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

    1 6 1 1 3 1 2 5 4 3

    Output should be 1+3+1+2 = 7 but it considers 5 as well and wrongly prints 12

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

Can anyone provide me a stress test like wa2 for my submission[submission:176043362]

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

I wasted 1 hour getting WA on Problem C, because, I thought each row or column can be painted with both red or blue colour! Then I noticed, only columns can be painted blue and rows can be painted with only red!!

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

    A similar thing happened to me in the past, a few extra seconds spent reading problem statements are worth it.

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

How to solve D

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

Please, share why this code getting TLE. Problem E time limit is 3 seconds. is q*n more than 3 seconds?

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

Thought in E we rearranged both s and t in the lexicographically least arrangement and then compare, wasted about 30 mins there, then re-read the question again and understood it properly, my ADD is really messing up with my performance, maybe it's time to cut down insta reels and tik tok ;(

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

Will 827div4 be unrated?

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

SlavicG

Is something wrong with the checker of problem F? I tried to hack and kept getting "Unexpected verdict" result.

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

    Same Issue here. I find many people using int to store the number of characters. When k and q are large I created a set of data to overflow the counter back to 1... But the hack gives me "Unexpected verdict".

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

    Sorry for the inconvenience, it should be fixed now.

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

C was the biggest anti-speedforces bait I've ever seen.

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

    C still needed weak testcases for full effect ;) The number of FSTs would probably set an all time high record if the testcases were weak.

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

Can anyone tell why I am getting wrong answer on test case 2 of problem E.. It is because of wrong implementation or because of wrong logic. Submission link

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

This is the first round that I AK :D

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

Imho problem F was easier than E and D

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

editorial?

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

It was a cool round. The last assignment is a lot of fun to underestimate why you can write n^2 code with one break and it will be accepted.

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

Overall this contest was good.

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

    hacks in F because some people didn't read the first line in the statement

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

How to do F, if s and t are initially empty ?

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

GEO THERMAL WROTE IT a newbie sadly

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


I had a problem accessing the page.
How can I not panic?
I hope this div not reflected in my rating.

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

Is the contest declared unrated?
The contest is shown under the 'only unrated' tab..

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

    It takes time to update rating. Until the rating is updated, the contest is shown under unrated tab only.

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

Wtf how is my F solution wrong, even some Gms had it wrong

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

    temp*y can be greater than 2e9. so you should use long long

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

      I'm an idiot i knew it should be long long and set the size variable to long long but the mul operation variables were integer.. Short sad story

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

Is it possible to solve E this way without getting TLE in test case 9? 176125836

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

    q*log(n) is right.q*n is not enough.you can see my code.It only needs 467ms.176015222

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

      Yeah but that's binary search. I was asking that can I do some improvement in this code only and get the job done? Or binary search is a must to reduce it to q*log(n)?

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

        of course we need binary search.q*n=4e10,it will need more than ten seconds

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

Guys, I mistakenly resubmitted my own code for problem D, and CF sent me this:

Attention!

Your solution 176041980 for the problem 1742D significantly coincides with solutions tllwtg/176009167, tllwtg/176041980. Such a coincidence is a clear rules violation. Note that unintentional leakage is also a violation. For example, do not use ideone.com with the default settings (public access to your code). If you have conclusive evidence that a coincidence has occurred due to the use of a common source published before the competition, write a comment to post about the round with all the details. More information can be found at http://mirror.codeforces.com/blog/entry/8790. Such violation of the rules may be the reason for blocking your account or other penalties. In case of repeated violations, your account may be blocked.

Dose that mean my account are going to be blocked? :(

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

I ranked ~400 in the round (~95 officially) but I found I was disqualified and I am accused of cheating. I wrote a post here. Please help by upvoting.

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

Something strange happened to me. For problem B, I used "goto" in my code, and the judge gave me WA ( 175907076 ) though the code works well in my computer, when I replaced it with "flag" , I got AC.( 176139742 ) Could someone tell me whats going on with "goto" in this problem? that would help me a lot, thanks : )

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

    It's because you don't read the input correctly. You are breaking early while reading the input so the values for the next test case start from the array of the previous test case, so all future values are just messed up.

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

https://mirror.codeforces.com/contest/1742/submission/175924333 https://mirror.codeforces.com/contest/1742/submission/175959376 I don't know why my code for this problem in 827div4 has been repeated by other's code. I don't know the people at all and if you see the links of code above , you could find that the codes could certainly made by different people. And the problem D , the solution I solved was right and simple. I can't really understand that this code could be repeater by others. Attention!Your solution 175924333 for the problem 1742D significantly coincides with solutions 0x4c/175924333, alitarekkk/175959376. Such a coincidence is a clear rules violation. Note that unintentional leakage is also a violation. For example, do not use ideone.com with the default settings (public access to your code). If you have conclusive evidence that a coincidence has occurred due to the use of a common source published before the competition, write a comment to post about the round with all the details. More information can be found at http://mirror.codeforces.com/blog/entry/8790. Such violation of the rules may be the reason for blocking your account or other penalties. In case of repeated violations, your account may be blocked.

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

My English is not good, so some of them are translated.

D guarantees that n is greater than or equal to 2, but they have n is equal to 1 in their data.

The first solution get Accepted. https://mirror.codeforces.com/contest/1742/submission/176077405

The second solution adds assert(n! =1) Then it gets Runtime error on test2.

https://mirror.codeforces.com/contest/1742/submission/176155308

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

MikeMirzayanov SlavicG I have been submitting my Java solution for problem E div4 827, and getting judgement failed verdict continuously. This happened at the time of contest as well. Kindly check.

Attaching the submission links : 175975446 176169782 176170045

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

Why Problem D coprime in Codeforce round 827(Div 4) is retesting

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

Hi everyone,

As a contestant I found that the test in the probem F wasn't good enough. I have all the prestest passed, but then somebody hacked me, so I checked what was the problem with my code and it was the size of a variant. I needed to put long long int and I used int, I think that it should give me wrong answer in a pretest, but it didn't.

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

Help me for find my mistake. I don't understand. https://mirror.codeforces.com/contest/1742/submission/176450420