Vladosiya's blog

By Vladosiya, history, 2 years ago, translation, In English

Hello! Codeforces Round 925 (Div. 3) will start at Feb/13/2024 17:35 (Moscow time). You will be offered 6-8 problems with expected difficulties to compose an interesting competition for participants with ratings up to 1600. However, all of you who wish to take part and have a rating of 1600 or higher, can register for the round unofficially.

The round will be hosted by rules of educational rounds (extended ICPC). Thus, solutions will be judged on preliminary tests during the round, and after the round, it will be a 12-hour phase of open hacks.

You will be given 7 problems and 2 hours and 15 minutes to solve them.

Note that the penalty for the wrong submission in this round is 10 minutes.

Remember that only the trusted participants of the third division will be included in the official standings table. As it is written by link, this is a compulsory measure for combating unsporting behavior. To qualify as a trusted participant of the third 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 1900 or higher in the rating.

Regardless of whether you are a trusted participant of the third division or not, if your rating is less than 1600, then the round will be rated for you.

Problems have been created and written by our team: myav, Gornak40, ibraevdmitriy and Vladosiya.

We would like to thank:

  1. MikeMirzayanov for help with ideas and Polygon and Codeforces platforms.

  2. nigus for red testing.

  3. vladmart, Gheal, KseniaShk for yellow testing.

  4. htetgm for purple testing.

  5. natalina, JuicyGrape, lockdown, kotikk for blue testing.

  6. RedDreams for cyan testing.

  7. the_Incharge, Aurora__, Longqiang for green testing

Good luck!

P.S. Happy Valentine's Day!

UPD: Let's continue streak of announces with photo of the authors :)

UPD2: Editorial

  • Vote: I like it
  • +385
  • Vote: I do not like it

| Write comment?
»
2 years ago, hide # |
 
Vote: I like it +24 Vote: I do not like it

Wow, you put a lot of effort to make a lot of quality div3. Thanks for a lot good div3 round to help beginner to advances in CP.

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Yeahhhh!!! Div 3 Letsssss Gooooo

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Div 3 are my favourite. Lots to learn.

»
2 years ago, hide # |
Rev. 2  
Vote: I like it +2 Vote: I do not like it

the round number and date is wrong please fix

»
2 years ago, hide # |
 
Vote: I like it +11 Vote: I do not like it

speedforces let's go

»
2 years ago, hide # |
 
Vote: I like it +4 Vote: I do not like it

Thursday, October 12, 2023?

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I hope this is my last round before cyan

»
2 years ago, hide # |
 
Vote: I like it +54 Vote: I do not like it

Thank WHO for red testing 😳

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

My first unrated Div3 I mog everyone

»
2 years ago, hide # |
 
Vote: I like it +7 Vote: I do not like it

don't make your gf sad, prepare gift after contest

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    cp and gf? nah man something doesn't feel right. Just don't touch grass and stay home I guess

»
2 years ago, hide # |
 
Vote: I like it -16 Vote: I do not like it

I had no idea authors could be so pretty. I'm blushing (,,>﹏<,,)

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it +4 Vote: I do not like it

    mmm, why?

    • »
      »
      »
      2 years ago, hide # ^ |
       
      Vote: I like it +4 Vote: I do not like it

      I was hoping the authors would see it and feel happy.

      Spoiler
      • »
        »
        »
        »
        2 years ago, hide # ^ |
         
        Vote: I like it +3 Vote: I do not like it

        No, I mean why you thought that authors couldn't look pretty. As far as I'm concerned they're all human beings, just like the rest of us

        • »
          »
          »
          »
          »
          2 years ago, hide # ^ |
           
          Vote: I like it +9 Vote: I do not like it

          If I became an author, I would be a good counter-example :)

          But you are correct. Everyone is beautiful. That's why its great to have pictures of the authors in the announcement.

»
2 years ago, hide # |
 
Vote: I like it +15 Vote: I do not like it

so sweet post. Happy Valentine's Day. Do spend time with ur loved ones, instead of attending contests

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I am the one in the button right on Valentine's day :⁠,⁠-⁠)

»
2 years ago, hide # |
 
Vote: I like it +6 Vote: I do not like it

I don't get it,why are authors making a 'C' with their hand?

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it +26 Vote: I do not like it

    May be because Mike also did the same on his picture (to hold the burger)?

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it +33 Vote: I do not like it

    It's not the letter "C", it's half a heart (we tried, ahahah) We wish the community a happy Valentine's Day!

    • »
      »
      »
      2 years ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      Got it,that makes sense,i need to go out and meet some real people.

»
2 years ago, hide # |
 
Vote: I like it -10 Vote: I do not like it

Thanks for the contest but why y'all throwing up gang signs?

»
2 years ago, hide # |
 
Vote: I like it +2 Vote: I do not like it

Valentine's Day ? Oh man, i am CPer

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

My first unrated contest

»
2 years ago, hide # |
 
Vote: I like it +90 Vote: I do not like it

They are so similar

»
2 years ago, hide # |
 
Vote: I like it -10 Vote: I do not like it

why are the names of the authors written in reverse

»
2 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Hopefully my last rated div3

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

why the solution will be out 5 minutes before the contest ends?

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Hope positve delta for all rated participant.

»
2 years ago, hide # |
 
Vote: I like it +20 Vote: I do not like it

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Good luck to everyone.I hope to become expert on this round.

»
2 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Hope to reach expert again

»
2 years ago, hide # |
Rev. 2  
Vote: I like it -13 Vote: I do not like it

Disgusting problem F

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it +12 Vote: I do not like it

    It's not, F is basically "Detect cycle in a directed graph".

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    you can do "F" just by making first line as 1, 2, 3, ... n, and these ai changes in next k — 1 lines too.

    Then for each line just check order is maintained (i.e. curr element is less than last)

    As an edge case: ensure "1" is correct in all.

    submission

»
2 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Got the right idea for F about an hour after the contest started but spent the next hour debugging double-hash. :(

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

please hint for C

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    You MUST choose x as the first OR the last element.

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    three possible ranges you will select from k to n , from 0 to n-k , or from i+k to n-k. k is the index is where there's no more duplicates from the beginning or end from the array, like [1,1,1,2,3,4,5] k is at index were ai is equal 2 , so we can make the range we select [4,7] , same from the back. i+k to n-k is when the duplicated at front is the same from the back . sorry for bad explaining

  • »
    »
    2 years ago, hide # ^ |
    Rev. 3  
    Vote: I like it 0 Vote: I do not like it

    You can look for the longest segment of equal elements from the start, let's call it a, and the longest segment of equal elements from the end, call that b. Now, there are two cases:

    (1)If the first and last elements are equal, you can choose the contiguous segment of elements not in either a or b. (notice, if len(a) + len(b) > n, the answer is zero. Else the answer is n — len(a) — len(b))

    (2)If the first and last elements are not equal, you choose the equal element as the element that comes in the longer segment. (notice, the answer in this case is n — max(len(a), len(b)))

»
2 years ago, hide # |
Rev. 2  
Vote: I like it +1 Vote: I do not like it

i am annoyed i couldn't get F i didn't think it will be cycle detection at all.

»
2 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Problem D is nice, thanks for the contest. But how to solve F?

»
2 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

I feel like idea of F was simple but the implementation was tedious. Also, loved G!

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Any hints for G?

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it +3 Vote: I do not like it

    Try reducing this problem to a stars and bars problem Try to think what are the prerequisites if we want to place the 4th block at any place same goes for the 3rd Think which blocks are the limiting factors and which we can take care of irrespective of their quantity Have a Great solve!!

»
2 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Maybe it's just me, BUT F seemed way easier than both D and E, although didn't spend much time on E after I saw F, which I had just the right idea for. Overall very fun Contest.

»
2 years ago, hide # |
Rev. 2  
Vote: I like it +25 Vote: I do not like it

Quick hints for all the problems before the Editorial comes out.

A: Just brute force on each index using 3 for loops.

B: As the water can't flow backward, therefore the amount of water in any prefix can only decrease or stay constant.

C: Check if all equal, else count prefix equal length and suffix equal length.

D: What if we store the remainders in pair<int, int>?

E: Replace each number by the count of its trailing zeroes, now play the game greedily.

F: We can easily create the order from the first 2 arrays given (if k = 1, then its YES). Just make sure to handle one edge case [1,2,3,5,4] and [2,1,3,5,4], basically those in which there are 2 possible orders)

G: Pieces 1 and 2 can only appear alternatively, and the pieces 3 and 4 will always fit in the between their occurences. Also, pieces 3 and 4 can be repeated, while 1 and 2 can't. Try fixing Piece 1 or 2 as the first piece in the chain, do you get some general pattern?


Spoiler
  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it
    • »
      »
      »
      2 years ago, hide # ^ |
      Rev. 2  
      Vote: I like it 0 Vote: I do not like it

      Easier way to solve F without using graph

    • »
      »
      »
      2 years ago, hide # ^ |
       
      Vote: I like it +5 Vote: I do not like it

      Yeah this subproblem looks way more easy and familiar, I was just hasty and went with my first thought.

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it +6 Vote: I do not like it

    In F, I think the simplest way to code is model it as a graph and use topo sort. I think that makes implementation really easy with template :)

  • »
    »
    2 years ago, hide # ^ |
    Rev. 5  
    Vote: I like it +1 Vote: I do not like it

    can up please tell what's wrong with this

    code
  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    I did F after constructing the graph and checking if the number of SCC is equal to $$$n$$$:)

»
2 years ago, hide # |
 
Vote: I like it +10 Vote: I do not like it

F — "Detect cycle in a directed graph."

Submission- 246203312

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

How to combine pieces in the second test case of problem G (one sample way would be enough, please)?

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I just wanna say thank you for making this contest, I was able to solve till F( can't believe I did this )

I think I have very unique solution for problem D: Problem D Solution

I used modular operations for storing single value in map

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Code editor is not working, keeps running and no result, makes the whole experience shit. Cant run test cases.

»
2 years ago, hide # |
 
Vote: I like it -11 Vote: I do not like it
  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    you just calculating binomial coefficient, how is this related to solving G?

    • »
      »
      »
      2 years ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      Because the only thing that came to my mind was:

      • place a 3 on this group (between 1 and 2),
      • or move to the next group

      which led me to the formula: $$$dp[i][j] = dp[i - 1][j] + dp[i][j - 1]$$$, and I didn't realize that it was effectively just comb(i + j, j), so that's what ChatGPT told me.

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it
»
2 years ago, hide # |
Rev. 2  
Vote: I like it +14 Vote: I do not like it

Here is how you can choose the next type of element to add in problem G.

Two nice observations:

  • This condition must be satisfied: $$$\left|c_1 - c_2\right| \le 1$$$.
  • Think about the problem without elements of types $$$3$$$ and $$$4$$$, then try to insert them in the generated chains.
»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

When I saw other's solutions,I found the problem E very easy. However,I think F is easier than E because I can get the idea to solve it without thinking.(if you know something about graph)

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I was wondering whether this contest gives any rating? I am 401 rated. I have participated and solved 2 problems but haven't got any rating. Can anyone tell me if i'll get any rating?

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Does the following work for F?

Rearranging any of the participants except the last one cannot change the last participant from the permutation. Therefore, we can find the real permutation by checking which one has the last participant only once. Now, that we have obtained the real permutation, we can compare all of the k inputs to the real one and check.

This doesn't work when k == 2 but in that case we can simply check subsequences ignoring the first two numbers.

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Loved the beautiful Stars and Bars problem (G) Got to the solution but didn't submit earlier as I was unsure if it would be rated for me Nonetheless Here's my solution in case any one wants a reference: https://mirror.codeforces.com/contest/1931/submission/246256160 :)

»
2 years ago, hide # |
Rev. 3  
Vote: I like it 0 Vote: I do not like it

As an expert I failed D: TLE on test 9. Here is my code: 246198274. Could anyone help me with debugging? I think this is O(nlogn).

Edit: This is O(y). Forget it

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

How to solve E? Didn't get any idea at all :(

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it +5 Vote: I do not like it

    1) Ans "yes" if number of digits in the last number >= m + 1. Anna in each step tries to reverse number with maximum zeroes on the end. Sasha in each step does concatenation number with maximum zeroes on the end with any number without zeroes on the end (number without zeroes on the end is guaranteed to exist, since it either exists initially, or Anna will make it her first move)

  • »
    »
    2 years ago, hide # ^ |
    Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    it is optimal for both of them to the choose the numbers which have most no. of zeros at the end

  • »
    »
    2 years ago, hide # ^ |
    Rev. 2  
    Vote: I like it +1 Vote: I do not like it

    multiset<pair<trailing_zeroes, digits>> and just model a game

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I think you should reduce the time limit of this problem. this submission -> https://mirror.codeforces.com/contest/1931/submission/246247517 runs in 1 second. this submission should not get AC because # of testcase is 10000 and this submission is executing a for loop of 200005 every test case. that's more than 2e9 operations.

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

!What is this submission code
is he know the testcase?

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

After successfully wasting 1.5 hour on B i smashed binary search in B

can someone hack it?

246247536

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    why would you even think of binary search . you already know that the good value is sum/n . that's the only way you can make tha array the same

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Video Editorial for problem B (Audio : Hindi) TUTORIAL VIDEO LINK

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Thanks to the authors for an interesting div 3 without clay and with tasks that are fun to solve. After this div and the Cognitive Technologies Olympiad, I realized that the name Gornak in the list of authors => good Olympiad/div.

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Can G be solved using inclusion exclusion ?

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

May I ask why I passed 3 questions but didn't receive a rating in the end? Or who should I seek help from? I really want this rating, thank you.

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Rating appears after 1 to 24 hours from the end of a contest, and if there is a hacking phase, like this contest, then it may last up to 24 hours or less.

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

in Problem E , i wrote code which was absolutely right, the only thing i missed was, if number>=10^m then number of digits should be >=(m+1) not >=m (it was pretty close :) )

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

How to solve Problem G?

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

wow that was very cool

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

really enjoyed this contest, particularly problem D. start to see some common patterns on int-mod problem..

»
2 years ago, hide # |
 
Vote: I like it +12 Vote: I do not like it

my respect to Aleksander Gornak

»
2 years ago, hide # |
 
Vote: I like it +5 Vote: I do not like it

I was getting runtime error (STATUS_ACCESS_VIOLATION) in E, during contest , but after contest when i submitted same solution it got accepted . runtime error during contest code link.
accepted code after contest. Thanks

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it +19 Vote: I do not like it

    The problem is this for loop here: for(ll i=vect.size()-1;i>=0;i-=2).

    In C++, the return type of std::vector::size is an unsigned integer. When vect is empty, then vect.size() - 1 becomes 0 - 1 which then overflows to UINT_MAX. This causes out of bounds error which is why your program got runtime error. (It seems that this is changed in C++20, which is why your other code got accepted)

    To fix this, you just have to convert vect.size() into any signed integer type. For example for(ll i=(ll)vect.size()-1;i>=0;i-=2). New code

»
2 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

One of the best rounds I've ever participated. Thanks to all the writers and testers for offering us such a round.

»
2 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

The best div3 round contest I've ever participated!Thank you!

»
2 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

when will the rating come out?

»
2 years ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

Can anyone tell me where have I made a mistake in these two codes? Only difference I have made from my side is making the capital N,small n? Basically I had initialised all visited array elements to zero in reset function. Thankyou in advance.

1st submission 246198873

2nd submission 246233252

  • »
    »
    2 years ago, hide # ^ |
    Rev. 5  
    Vote: I like it +1 Vote: I do not like it

    I don't understand why exactly gives you another answer (actually I'm more curious of how didn't get you RTE hahaha weird stuff)

    But the reason why the change works is because in the WA submission, you have the following code:

    vi g[N];
    void reset(){
    	fr(i,0,N){
    		g[i].clear();
    		vis[i]=0;
    		vis1[i]=0;
    	}
    }
    

    and fr is #define fr(i,a,b) for(int (i) = (a); i <= (b); (i)++)

    So, the cycle in reset() will access to the position $$$N$$$. But the arrays g, vis and vis1 are of size $$$N$$$, I change you code putting a -1 and now it gets TLE, that makes a lot of sense, because $$$t = 10^4$$$ and $$$N=2e5+69$$$, so you will do around of $$$2\cdot 10^9$$$ operations just to reset.

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

In Question 4 this code exceeds time limit on test case 33 cant understand why its o(n) approach can someone please help me?

include<bits/stdc++.h>

using namespace std;

define ll long long

int main() {

int t;
cin >> t;
while(t--)
{
    ll n, x, y;
    cin >> n >> x >> y;
    unordered_map<ll, ll> dp;
    ll a[n];
    ll ans = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        ll f = (x - a[i] % x) % x;
        ll l = a[i] % y;
        ans += dp[f*y+l];
        dp[(a[i] % x)*y+a[i] % y] += 1;
    }
    cout << ans << '\n';
}
return 0;

}

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Worst case time complexity of unordered map is o(n) while normal map is of o(logn) that's why it is giving Tle. I got AC with your solution by just changing unordered map to normal map

»
2 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

But may I ask why I still haven't received a rating? It should have been a long time since the hack phase ended. I really want the rating for div3 this time, thanks.

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    You must wait for some more hours after the system test. Codeforces needs time to calculate rating changes. Just chill

»
2 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Why there is no rating change? My rating is less than 1600

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    It takes a while after the system test for codeforces to remove cheaters and recalculate the rating changes.

    By the way, have we met somehow before?

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

can anyone just tell me which are valid patterns in G? I can't find any for 1 2 5 10

»
2 years ago, hide # |
 
Vote: I like it +2 Vote: I do not like it

when it will be rated?

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I am new to code forces this is my first contest, I have solved two questions still didn't get any rating. Did I miss anything?

»
2 years ago, hide # |
 
Vote: I like it +6 Vote: I do not like it

Give me my rating pls((

»
2 years ago, hide # |
Rev. 3  
Vote: I like it +4 Vote: I do not like it

Finally blue. Was a great experience.