Vladosiya's blog

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

Hello! Codeforces Round 946 (Div. 3) will start at May/20/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.

Round is based on UKIEPC 2024: Spring Practice. Please refrain from participating in this round if you are familiar with the tasks of this competition.

I would like to thank:

  1. Authors of the original competition: Aksenov239, MaxBuzz, RobinFromTheHood, darnley, izban, pkhaustov, lsantire, az453, fedor.tsarev, Shoaib Jameel.

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

  3. -is-this-fft-, peltorator, tute7627 for red testing.

  4. senjougaharin, kaikey, gmusya, nskybytskyi, Giga_Cronos, diskoteka for yellow testing.

  5. TypeYippie, kzyKT, tepamid, ahshafi for purple testing.

  6. Abo_Samrah, Zandler, sam07a, YESMAKHAN, xygzy, Klaus26 for blue testing.

  7. Morvolzz, dasha..zhilina, sutekine, Muhsen, Gojova, Acanikolic73 for cyan testing.

  8. You for participation.

Good luck!

UPD: Editorial is out.

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

»
2 weeks ago, # |
  Vote: I like it +43 Vote: I do not like it

well-balanced div3 round, GL for all participants 🏆

»
2 weeks ago, # |
  Vote: I like it +13 Vote: I do not like it

I can barely contain my excitement! I hope this will be a good one! GLHF!

»
2 weeks ago, # |
  Vote: I like it +36 Vote: I do not like it

As a tester, I hope you to enjoy the contest. Tasks are quite interesting and educational. Good luck!

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

    thanks for contest. I am exciting

  • »
    »
    12 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Can I get the following test case:

    Test Case 2: wrong answer 1110th numbers differ — expected: '5', found: '4'.

    • »
      »
      »
      12 days ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      int t =0 ;

      void testcase (){

      if (++t==1110){
                  for (int  i = 0 ; i <n ; ++)
                            cout<<arr[i]<<'|';
                  cout<<"\n";
                  return  ; 
          }

      }

      • »
        »
        »
        »
        12 days ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        try to avoid seeing your wa this will affecr the ability of discovering wa

    • »
      »
      »
      10 days ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      i also got this same error, if u get the solution to this let me know

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

Good round, come and participate.

»
2 weeks ago, # |
  Vote: I like it +16 Vote: I do not like it

Another Vladosiya round!!!

»
2 weeks ago, # |
  Vote: I like it +22 Vote: I do not like it

hoping to return back the blue handle

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

As a participant I have to say im excited.

»
2 weeks ago, # |
  Vote: I like it +21 Vote: I do not like it

wishing to get my Pupil back

»
2 weeks ago, # |
  Vote: I like it +13 Vote: I do not like it

Well GLHF, let's gain some rating!

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

as a tester , i hope you enjoy the round , a realy very good round <3

»
2 weeks ago, # |
  Vote: I like it +34 Vote: I do not like it

As a tester, I encourage you to read all the problems.GL and Happy Coding.

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

orz

»
2 weeks ago, # |
  Vote: I like it +13 Vote: I do not like it

Hope i can solve till E this time

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

Waiting for this contest. Thanks codeforces

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

OMG Vladosiya Round! <3

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

I hope I'll become pupil this time

»
13 days ago, # |
  Vote: I like it +17 Vote: I do not like it

Looking forward to an AK, and GLHF to all participants, rated or not!

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

you guys are doing so good... i'm trying my best just to stay at pupil

»
13 days ago, # |
  Vote: I like it +1 Vote: I do not like it

Hope to reach cyan this contest : >

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Mewing cat ready for the contest

bye bye

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

time for green

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

good luck for everyone:)

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Hope for a good contest.

Best wishes everyone <3

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

wishing all GL , Hope i will become green in this round

»
13 days ago, # |
  Vote: I like it +17 Vote: I do not like it

Beautiful Contest...

I Loved Solving the problems...

Especially the relation "Money Buys Less Happiness Now" with "Money Buys Happiness" won my heart :)

»
13 days ago, # |
  Vote: I like it +16 Vote: I do not like it

Thanks for nice tasks.

Funny that I solved G by accident couple months ago.

»
13 days ago, # |
  Vote: I like it +1 Vote: I do not like it

E was tough

  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Teach me your ways big bro you’re so strong

    • »
      »
      »
      13 days ago, # ^ |
      Rev. 6   Vote: I like it +11 Vote: I do not like it

      E had a nice dp thing. Take dp[i][x] to mean the minimum number of pounds you need in order to obtain at least x happiness at month i.

      The transitions are:

      for a certain happiness x, we know that dp[i][x] is at most equal to dp[i — 1][x] (that is, the answer for the previous month). dp[i][x] can also be dp[i — 1][x — h[i]] + c[i] if c[i] + dp[i — 1][x — h[i]] <= the amount of money we have garnered so far.

      dp[i — 1][x — h[i]] + c[i] represents the minimum cost to get at least x happiness assuming we buy happiness at month i. Of course, we can only afford this if it is less than our current amount.

      We don't want x — h[i] to go below zero. So dp[i][x] = min(dp[i — 1][max(0, x — h[i])] + c[i], dp[i — 1][x]).

      After this, in order to make the dp[i] represent the minimum number of pounds to get at least x happiness, we just let dp[i][a] = min(dp[i][a], dp[i][a + 1]) for a going from the sum of all happiness to 0. Aka just take suffix minimums.

      The base case happens at month zero (or at month 1 actually since you technically have no money at month 1). The minimum number of pounds we need in order to obtain 0 happiness at month 0 is 0. The minimum number of pounds we need to obtain x >= 1 happiness at month 0 is infinity.

      The answer will be the highest index in dp[m] who's value is not equal to infinity.

      There was a lot happening in this problem.

      • »
        »
        »
        »
        13 days ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Ohh I see it now! I thought of dp[m][h] but instead assumed min cost to get exactly h and couldn't move anywhere with transitions so weak.

        Thankyou this solution is very good, I hope to achieve this level of dp sorcery soon.

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

In problem C, I have wasted a lot of time in addition to 3 wrong answers because I thought that 1 <= ai <= 9

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

fail to solve D

hardest Div3 I've ever taken

byebye cyan hello green

  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Me too. I failed on C but succeeded on D. Even D takes a lot of time. Why we should move both the rover and the helicopter? If we may only move one, it will be much easier.

    • »
      »
      »
      13 days ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      yes, I do aware that but still, implementation was too heavy

      there are too much corner cases, loc easily beyond 100

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

Div. 3 like Div. 2.5

  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    more like Div3: Algorithms, Div 2+: Implementation. I spent over an hour trying to debug F.

    • »
      »
      »
      13 days ago, # ^ |
        Vote: I like it +3 Vote: I do not like it

      I agree first 4 were all implementation based.

    • »
      »
      »
      13 days ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      yeah same, i only realized after like 30 min that they for some reason swapped the x-axis and the y-axis. couldn't solve G (in contest) then :(

»
13 days ago, # |
Rev. 2   Vote: I like it +21 Vote: I do not like it

Though, I was not able to solve it, E was amazing.
Though, I was able to solve it, C was disgusting.

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

humiliating

»
13 days ago, # |
  Vote: I like it +3 Vote: I do not like it

The hardest div 3 I've ever seen.

»
13 days ago, # |
  Vote: I like it +3 Vote: I do not like it

(corner_case)Forces

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Can someone pls tell me how did you solve que C? I tried solving it using brute force and got TLE multiple times 261901233

  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    that's a $$$O(N^{2})$$$ time complexity , you should try less

  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Think of how find the number of beautiful pairs of triples that differ in the third element... then think of how to extend it

»
13 days ago, # |
  Vote: I like it +4 Vote: I do not like it

good tasks

»
13 days ago, # |
  Vote: I like it +36 Vote: I do not like it
  • »
    »
    13 days ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    C was tough or it uses some specific technique that i wasn't aware of.

    • »
      »
      »
      13 days ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      check the tuples where item of position K is unique. Tuples's positions = {0,1,2}

      I will show logic for K=0, but similar logic can be used for K = 1 and K = 2.

      For each tuple. Create a map that stores {1,2} as a key and a list of integers the 0s as values. Then sort that list. Then you can figure out how many items are strictly less than n, with a linear scan.

      • »
        »
        »
        »
        13 days ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        i did the same but miscalculated the number of tuples.I think its time for solving some Combinatorics problems.

      • »
        »
        »
        »
        13 days ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        I also thought of the same approach, but spent a lot of time implementing it and miscalculating

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Is there any solution for E using maps? If yes, can someone fix my code 261908381?

  • »
    »
    13 days ago, # ^ |
      Vote: I like it +6 Vote: I do not like it

    Well I tried to optimize your code, eliminated the use of one map in this submission 261926879. But it still gave TLE.

    I initially also got a TLE during the contest on test case 14, that is because I did not notice the upper bound over all the test cases was on sum of hi and not m.

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Hardest Div 3 ... Only div 3 B solved ... can some one tell me the logic of C

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

    use a map for each triple:

    count += the number of triples that have atleast 2 similar elements

    count -= the number of triples that are the exact same

    • »
      »
      »
      13 days ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      hmmm, do map can carry triplets .... i think i have to learn stl library in brief .. Thank you .

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

        I just used a map<vector<int>, int> and it passed.

      • »
        »
        »
        »
        12 days ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        map can carry any pair of datatypes(map<T,T>)

        for the case of task C, it is possible to solve it using 4 maps, 3 of them are map<pair<int,int>,int> and the 4th one is map<tuple<int,int,int>,int>(for 3 equals)

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

is D that easy ? there are a lot of submissions...how to solve it

  • »
    »
    13 days ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    the most important is to notice that the opposite directions like (N, S) and (W, E) are remove each other.

  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    For me 4th was easier than 3rd. I solved the 3rd one but wasn't able to optimize it. I just needed few min to submit 4th.

  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I paired up N with S and E with W. For each pair, I assign either both H or both R. For example, if some pair of N and S are assigned H, then they cancel out, and they effectively do not move the helicopter.

    There will be unpaired ones left over. We just have both the H and R assigned to an equal number of unpaired ones for each direction, then they will end up in the same position. If H and R have equal of each, then that implies that the total number of unpaired ones must be even for each direction. For example, if we have NENNNE, then there are 4 N and 2 E, so we just let H and R have 2 N and 1 E each. NENNEE is not possible, because there are odd N, or odd E.

  • »
    »
    12 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    the easiest solution would be to just follow the moves of other robot and brute force it. there is one specific case when following solution won't work and that is when we have one movement of each direction each. we can handle that separately. here's my submission

»
13 days ago, # |
  Vote: I like it +2 Vote: I do not like it

I took more than one hour to solve D

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Please add an option to filter out non-official (* asterisk) contestants. How can we see the real standings without such an option

  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    There is a checkbox called "show unofficial" on the top right corner of the standings page, untick it

»
13 days ago, # |
  Vote: I like it +3 Vote: I do not like it

how did so many people understood this: each character in the string s is replaced by its symmetric character from the string r (the first character of the string r will be replaced by the last, the second by the second from the end, and so on).

I feel like I lack the ability to guess the problem statement

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

    when I have difficulty in understanding the statement i directly go to the example, and I think the example was clear

  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Took me some time but using set and map kind of helped.

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

    Yeah the wording of that problem tripped me up too. I interpreted it as each character in string r acts as a key with the value as the symmetrical character in string r. Then search each string s character in the hashmap to find its decoded character. It worked in the end

  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I was only able to understand it because of the illustration that was provided.

  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    There is a picture in the problem statement that explains it

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

AHHHHHHH....should've tried 4th instead of wasting time on 3rd.

  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Yeah, you're right. Thankfully I thought of this soon enough to solve D, otherwise I would have not been able to solve either of them in time.

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Hardest div 3 ever implementing C takes a lot of time and even D is also tough to implement

  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    exactly , D took lots of conditions to print correct answer , it should be yes / no type with C and C should be D.

  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I got tle in D couldn't optimize

  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    i tried c problem with hash, wasn't much difficult to implement. but i got intituion for d but couldn't implement it. a lot of conditions were there

    • »
      »
      »
      13 days ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I also implemented C with hash map by making pair of two elements of a triplet as key and another element of triplet as value,But I overcomplicated to optimise more.

      D is very tricky to implement because of the condition that each device must execute at least one instruction.

      • »
        »
        »
        »
        13 days ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        yeah in c u can manage 4 maps string key and int value, where first map denotes triplet starts from a[j],a[j+1], second map triplet end a[j+1],a[j+2] third a[j] and a[j+2] and fourth having triplet itself. so at any position we can get total triplets.

        for refrence:

        unordered_map<string,int> m1;
         unordered_map<string,int> m2;
         unordered_map<string,int> m3;
         long long ans =0;
         for(int i=2;i<n;i++) {
        
            string s1 = to_string(a[i-2])+","+to_string(a[i-1]);
            string s2 = to_string(a[i-1])+","+to_string(a[i]);
            string s3 = to_string(a[i-2])+","+to_string(a[i]);
            string s4 = to_string(a[i-2])+","+to_string(a[i-1])+","+to_string(a[i]);
        
            long long a1 = 1ll*m1[s1];
            long long a2 = 1ll*m3[s2];
            long long a3 = 1ll*m2[s3];
            long long a4 = 1ll*m1[s4];
          // finding all triplet
            ans+=(a1-a4)+(a2-a4)+(a3-a4);
            // updating tripletes
            m1[s1]++,m3[s2]++,m2[s3]++,m1[s4]++;
        
         }
      • »
        »
        »
        »
        13 days ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        i got d but after the contest done lol !!!, like we can just manage their states of R and H

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Problems were kinda hard according to div3

»
13 days ago, # |
  Vote: I like it -13 Vote: I do not like it

The time limit and constraints of C could be managed better. Other than that, the problems were nice.

»
13 days ago, # |
  Vote: I like it +1 Vote: I do not like it

any hint for E? I tried dp[m][x] using map but obviously I get TLE;

  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Try dp[h] = max money we can have after buying $$$h$$$

    • »
      »
      »
      13 days ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      vstiff can you tell your transitions ? for the dp states and why so reason too please

      • »
        »
        »
        »
        13 days ago, # ^ |
        Rev. 3   Vote: I like it 0 Vote: I do not like it

        Basically just two transitions:

        1) buy everything

        if dp[k] >= c {
          dp[k + h] = dp[k + h].max(dp[k] - c);
        }
        

        2) get salary

        dp[k] += x;
        
  • »
    »
    13 days ago, # ^ |
    Rev. 2   Vote: I like it +1 Vote: I do not like it

    I've solved with dp[m][total_happiness]

    obviously it passed

    • »
      »
      »
      13 days ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Hi daud04, I see you have done recursive DP, can you please explain your solution in detail if possible? I couldn't think of a way dot it recursively as money from previously bought happiness can still be leftover and help us in future, I did it iteratively : link , If anyone else know this please feel free to pitch in.

      • »
        »
        »
        »
        13 days ago, # ^ |
          Vote: I like it +1 Vote: I do not like it

        my dp state is [index][required_happiness] and it returns the minimum required money i must have before entering the state to buy required happiness.

        (i'm just going forward here)

        as a knapsack dp, there is 2 option.

        if i buy the happiness of the index , i must have a[index] value now , and must have the to money to buy remaining happiness from next indexes, as i can store this k for next indexes , substituted k from next dp cost.

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

nice problem set! i have seen same ideas like in these problems before, but they are usually in div2 and too hard to solve. thank you for introducing them for me!

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

I hoped Brute Force would work on Problem C with 4s Time Limit but NOPE...

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Really nice contest. Problems were not too difficult, and liked the problem E especially. Problem D was implementation heavy and if not for some mistakes in it and time wasted in debugging it, this would have been my first contest to solve all problems as I solved G just few minutes after contest ended :(

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

I have a bonus problem (Harder version of problem $$$C$$$) : A pair of triplet is good if elements in any two positions are not equal and equal in one position , count the number of good pairs

  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    wouldn't it be equal to the total number of pairs — number of pairs with exactly 2 matches (current problem) — number of pairs with all 3 matches?

    • »
      »
      »
      13 days ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      you also have to subtract number of pairs with 0 matches

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Tough C, I come up with the the solution pretty quickly but spent many times to implement it 261860863

And D also a terrible implementation(at least for my code) I neerly smashed my laptop when I realize what I am coding 261856874

And can someone help with my E? At first I thought it was a signed int overflow (because it did't WA until test case 10) but it seems to be more than that... 261884565

  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Not getting what is wrong with my memoization solution of E: 261908791

    Appreciate the help if anyone could.

  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    D 261878026 seemed easier to implement than C 261849652. My C almost took 1.2 secs. I think it might get hacked lol

    • »
      »
      »
      13 days ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      My solution for C uses four maps and an idea of inclusion and exclusion. But I couldn't solve D in +1 hour.

      261867166

  • »
    »
    13 days ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    I tried submitting your code 261934590 and got it accepted. The idea was that a particular state can be visited many times, you assumed that it can be only once.

    Code
    • »
      »
      »
      13 days ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      Oh my god, I actually have realized it but my brain didn't go right and made huge amount of small mistakes when I tried to modify it :(

      And It should have been Accepted if simply to add a more ! in my last minute submitted code rather than failed in test case 1 (:_;)

      Anyway, thank U very much orz

»
13 days ago, # |
  Vote: I like it +8 Vote: I do not like it

Are all submissions tested against the test cases from successful hacks at the end of the hacking phase?

»
13 days ago, # |
  Vote: I like it +3 Vote: I do not like it

Hardest div3 I've ever taken, C is harder than an average C in div2.

  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    A: Really easy problem, as it should be (800)

    B: Already semi-difficult, similar to 2B in some ways (1000).

    C: Extremely difficult to implement and solve for its position, analgous to easy-mid Div2C/Div3D (1300)

    D: Easy to solve, ananoying to implement(1300).

    E: Elegant but hard. DNS (1700).

    F: Got me stuck in debugging hell for an hour (1900).

    G: DNS (2000)

  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    ???

    I'm a noob and it was very easy IMO. Done it in 12 minutes.

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

*Deleted

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

it-sover

got AC on D after contest simply by removing pre-check, but simulate answer then checking correctness.

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

I had the right idea on C with the three maps but I couldn't think of the way to sum them up correctly :(. Problem D was really nice, the concept and everything. E was also cool but I didn't really have time to solve it. First time I solve D and don't solve C on a contest which I didn't expect to be fair but I'll take it.

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it
»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

In F, what if k is fixed in input and instead of moves being given, both players play optimally to maximize their score?

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

i wish that problems next time be less implementation T_T

»
13 days ago, # |
Rev. 2   Vote: I like it +3 Vote: I do not like it

I am surprised that ChatGPT was able to solve problem G in this round. To be more specific, I was stuck on G, so I put the problem statement into ChatGPT, which is a hot topic right now, to try to get some clues. Initially, it presented me with an incorrect greedy code (a simple greedy method of looking from the front and buying if possible). Then, I provided an example that would fail with this solution (Test Case 3: 6 4, 4 10 3 8 6 10). To my surprise, it then gave me the correct greedy algorithm using priority_queue! (This might have been a lucky punch, though)

I am unrated so I am not particularly affected, but for contests like div-3/4 with many typical problems, ChatGPT might be able to solve quite a lot of them...... (I haven't tried it yet, but I think it can also solve problems like F, which have straightforward and typical approaches but may be a hassle to implement.)

(My prompt: https://chatgpt.com/share/05ad0c4b-33a1-4480-8f46-c7a87a60f019 we need to fix some details (input and the timing of adding X), so we can't just copy and submit, but the main idea is totally correct. I think if the prompts were further elaborated, the code will follow those instructions too.)

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

    Problem G was a pretty standard priority queue problem. After taking current happiness if the cost becomes higher than the money we have. We have to remove some happiness we prevously take. Which one should we remove ? Of course the most cost happinesses.

  • »
    »
    12 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I gave problem E to GPT-4, and after 2-3 attempts it come up with an almost correct answer, and then i provided some hints and i got the correct answer.

    Here is the almost correct solution

    and here is the correct solution

    But don't get the wrong idea, I didn't use CHATGPT during Contest, nor do i want to suggest using it. I just wanted to check the capability of GPT-4 for dynamic programming problems.

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Any insights into why this submission is giving an incorrect result for test case 5: 261917349

  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    You can use long long instead of int.

    • »
      »
      »
      13 days ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Just realized and got ac, 'integer overflow' destroyed this contest :(. Didn't even spent time on D which was very much implementation only.

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Problem C is nice, I was so intense solving it, switched to C++ after getting MLE with Haskell, couldn't make it in time but still made my day.

Screenshot

Thank you guys for a nice contest!

»
13 days ago, # |
  Vote: I like it +1 Vote: I do not like it

Thanks for such a great contest. I loved it

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

How to solve C?

Can anybody please tell me why I'm getting WA on test 4? Submission

  • »
    »
    13 days ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    With 1 <= a[i] <= 1e6 then these may not work:

    int abc = (v[i]*100)+(v[i+1]*10)+v[i+2];

    int _ab = (v[i]*10)+v[i+1];

    int _bc = (v[i+1]*10)+v[i+2];

    int _ac = (v[i]*10)+v[i+2];

    I think you can use pair instead of combining into a single int value.

»
13 days ago, # |
  Vote: I like it +43 Vote: I do not like it

G was pretty similar to this problem: 1526C2 - Potions (Hard Version)

»
13 days ago, # |
  Vote: I like it +6 Vote: I do not like it

Great contest, but I think that problem A could have been written in a better way: there are too many people who did it after 10 mins, meaning that the statemenet was not clear at all. Something like "an app can only be placed on a single screen" would have been enough. I was (wrongly) thinking of application on multiple screens, so that, e.g. 4 screens could contain 15 y app. Hope next time I'll be sharper in statement comprehension

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

I am unable to figure out why my C is failing

https://codeforces.com/contest/1974/submission/261920538

It fails on 1110 testcase on Unit Test 2.

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

Please explain why D is failing on test 4 261864972.

»
13 days ago, # |
  Vote: I like it +3 Vote: I do not like it

Can someone explain why my solution 261888809 with $$$N=10^5$$$ failed, but the same solution 261919448 with $$$N=$$$$$$\sum\limits_{i = 1}^mh_{i}$$$ passed in 1974E - Money Buys Happiness where $$$N$$$ is the maximum number of elements in $$$dp$$$ array. I guess my time complexity is $$$O(N*M)$$$ which should pass. And what does this statement It is guaranteed that the sum of $$$\sum_{i}h_{i}$$$ over all test cases does not exceed $$$10^5$$$ means?

  • »
    »
    13 days ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    I got the same TL as you because I initially did dp with $$$5 \cdot 10^4$$$.

    The problem is $$$t <= 1000$$$, so taking in your case dp till $$$10^5$$$ will make the worst case of $$$10^5 \cdot 10^3 \cdot 50 = 5 \cdot 10^9$$$, which is too much. (in my case it was twice less, but still too much).

    But taking $$$N = \sum_{i = 1}^m h_i$$$ resolves this, cuz then the worst case will be $$$m \cdot \sum_{i = 1}^t N_i$$$, but we know that sum of all $$$N_i$$$ over $$$t$$$ cases is not greater than $$$10^5$$$, then the worst case will be $$$50 \cdot 10^5 = 5 \cdot 10^6$$$ which is good enough.

    • »
      »
      »
      13 days ago, # ^ |
        Vote: I like it +3 Vote: I do not like it

      Oh yeah, now I realised when you mentioned it, basically overall time complexity is $$$O(T*M*$$$$$$\sum_{i}h_{i})$$$ and they have mentioned that $$$(T*$$$$$$\sum_{i}h_{i})$$$$$$\leq10^5$$$ so worst case will be $$$5*10^6$$$ which is fast enough whereas in my case, it will be $$$5*10^9$$$ which is TLE. Thnx mate.

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Problem C and D sucked the living soul out of me. Took whole 2hr to solve them. Really hard for a Div3.

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

C was unusually hard for Div3. E was nice.

Hopefully back to blue after this one.

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

I got the correct intuition for C but then I thought HashMap<Integer,HashMap<Integer,HashMap<Integer,Integer>>> must not be the intended solution, should have continued

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Is E solvable using recursive dp?

  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    i implement recursive dp but it gives a wrong output my dp state is dp[index][buy or do not buy]

    code
    output

    let me know if you were able to solve it using recursion or any other dp state

  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it
  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I found this submission which uses recursive dp : https://codeforces.com/contest/1974/submission/261868908

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it
»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Problem B is getting too many successful hacks. Can someone tell me what seems to be the problem with the solution approach of those who are getting hacked.

  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    How does an O(n) solution lead to a TLE hack in particular?

  • »
    »
    13 days ago, # ^ |
      Vote: I like it +14 Vote: I do not like it

    what they did wrong was they declared the answer as an empty string and instead of pushing m[s[I]] back , all of them added it to the current string and replaced the current string. This made each operation having a cost of i(current) length , giving the end time complexity of O(n^2)

    Wrong approach => ans = ans + map[s[i]]

    Correct approach => ans.push_back(map[s[i]])

    • »
      »
      »
      12 days ago, # ^ |
        Vote: I like it -12 Vote: I do not like it

      That is completely misstatements. ans = ans + mp[s[i]]; doesn't lead to O(n^2) complexity.

      • »
        »
        »
        »
        12 days ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Actually, I tried to change one of hacked submission this way and it worked. Sad that it wasn't caught by our max test.

  • »
    »
    12 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    unordered_map is easily hackable. Don't know what's wrong about default map solutions.

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Can someone explain the second last given test case of problem E?

  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    you can buy 2,3, and 5th tokens to get maximum happiness.

    • »
      »
      »
      13 days ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Okay now i see, i understood the question completely wrong. Thanks

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

'C' is quite tricky implementation!!!

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

can we solve E with recursive dp ?

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

I would appreciate your kindness if any of you could just debug my code for E, Thanks. https://codeforces.com/contest/1974/submission/261937456

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Thank you for the contest codeforces! Newbie here...Felt C was bit harder compared to D , anyone else?

»
13 days ago, # |
  Vote: I like it +3 Vote: I do not like it

good round, especially like F and G this round.

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

20 lines of code for problem D

link

who less?

  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Little suggestion to turn 20 lines of yours to 15. Check this part:

      for(char c: ss){
        if(c == 'W') pm['W']++;
        if(c == 'E') pm['E']++;
        if(c == 'N') pm['N']++;
        if(c == 'S') pm['S']++;
      }
    

    Simplify it to for(char c: ss) pm[c]++;. Easier debug this way too.

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Only if I wouldn't have spent so much time on C :(

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

for Problem E, is it the right approach to find the minimum number of money required to obtain x amount of happiness given i months using dp?. And then check what is the maximum possible happiness for which he can pay the money.

  • »
    »
    13 days ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    Yeah. it's right. I did the same way.

    • »
      »
      »
      13 days ago, # ^ |
      Rev. 2   Vote: I like it +3 Vote: I do not like it

      Thats great.Can you please explain what were transition eqn. you wrote, I am not able to find bug in my code

      • »
        »
        »
        »
        12 days ago, # ^ |
          Vote: I like it +1 Vote: I do not like it

        knapsack

      • »
        »
        »
        »
        12 days ago, # ^ |
          Vote: I like it +1 Vote: I do not like it

        as a knapsack dp, there is 2 option.1. if i buy the happiness of the index , i must have a[index] value now , and must have the to money to buy remaining happiness from next indexes, as i can store this k for next indexes , substituted k from next dp cost.

»
13 days ago, # |
Rev. 2   Vote: I like it +3 Vote: I do not like it

My ugly solution for D, but it works.

C and D are much tougher than regular Div3. Btw, a tip for the likes of D is jotting down all possible negative cases first, then either deal with the correct one or a much more trivial yes-or-no decision making.

Btw, anyone having a hint for G? I have a few ideas but I'm afraid I was overthinking at contest... (Nvm, I read a comment above and realized I was way too stupidly overthinking... T.T)

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

It was the coolest Div. 3 that I have ever done. However I did it well, I solved A-D tasks.

In my point of view, C was way harder than D. I did a ugly implementation with a giant code.

I expect to get green.

Thanks for the contest !!!!

»
13 days ago, # |
  Vote: I like it +5 Vote: I do not like it

Thanks for the contest! The problems were of pretty good quality as compared to recent div3 rounds. Hoping to reach Expert by the end of main tests!

»
13 days ago, # |
  Vote: I like it +1 Vote: I do not like it

implementation forces with too easy G. E and F were better imo.

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

My solution for problem-D assign first N-S to Robot and E-W to Helicopter and track the positions.
My Solution

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

i got a problem with the submission i submitted the code but till now it is showing as it is in queue can u check it once

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

What are some approaches that can be used to solve F? I was thinking either some sort of dp or something with geometry. That is to say, we somehow determine the number of points in a bounding box, and each cut makes this bounding box smaller. Then, by keeping a record, we can determine the numbers of points obtained for each cut. Or are these ideas a bit to "direct"?

  • »
    »
    12 days ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    It's direct, but it's kinda the motive of it. When moving the bounding box, you'll figure the points that would be left out of the box.

    Maintaining those points would require a sorted data structure with add/find/delete operation — as this data structure should add the points initially, find the points that are before/after a certain threshold, and delete those points. Still the number of points in the original box is quite large, so these operations should be fast enough instead of a naive linear one in array. For my most convenience, AVL/RBtree-based data structures (i.e. set at C++ and TreeSet at Java) should work well enough.

    • »
      »
      »
      12 days ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Can you explain your idea of how you deleted elements from the opposite dimension. I mean, if the move is U or D, how did you deleted those coordinates from the data structure where the coordinates are stored optimally for L/R operations (if you even are using a 2nd DS for that matter) ?

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

        First, my solution, just in case my words were unclear.

        We'll store two different sets for two dimensions, each will store a tuple $$$(x_i, y_i, i)$$$, and sorts them accordingly by the dimension defined. Thus, each point has two copies: one at the L/R set, the other at the U/D set.

        If cutting from a dimension, for example L/R, we can list the tuples that would be excluded from the L/R set, thus getting their indices in the process. With the indices, we can reconstruct the corresponding tuples from the other U/D set, and delete them as well. With this, each tuple will only be accessed/constructed/deleted twice at most, keeping everything $$$\mathcal{O}(n \log n)$$$ just fine.

»
12 days ago, # |
  Vote: I like it 0 Vote: I do not like it

lets go!!! pupil coming back. thanks for this round. my solution to D is way too stupid and I don't even have a solid proof/reasoning on why it passes but AC is AC. Getting Pupil back with specialist performance. Lets go!!!!

»
12 days ago, # |
  Vote: I like it +15 Vote: I do not like it

Oy blin I had fun this round. E was pretty, unfortunately I couldn't solve it.

»
12 days ago, # |
  Vote: I like it +3 Vote: I do not like it

The naming of problem 'E' is really interesting!!!

»
12 days ago, # |
  Vote: I like it 0 Vote: I do not like it

I read so many comments about C being too hard. Can anyone tell me what was so hard about it? Wasn't it a simple map count problem? If it were Div.2 I would've used better hashing just to be more sure.

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

    I think it's not very easy to come up with the idea of counting each pair (1-2, 2-3, 1-3) individually, as well as it's not something you'll see much in easier problems to count a pair or a tuple as a whole. If you're used to such problems then it's easy, but not for most (like, 2/3 of the official participants) who need to challenge 3C problems.

»
12 days ago, # |
  Vote: I like it 0 Vote: I do not like it

The early rating updation nowadays means, the system has been updated.

»
12 days ago, # |
  Vote: I like it 0 Vote: I do not like it

For problem G, can someone please spot the error in this code . I am trying to use a multiset to store the costs at which happiness has been bought and then using the upper_bound function.

#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
typedef long long ll;
using namespace std;
int func(auto &cost,int m,int x){
    multiset<int> s;
    int cur_money=0;
    for(int i=0;i<m;i++){
        if(cur_money>=cost[i]){
            cur_money-=cost[i];
            s.insert(cost[i]);
        }
        else if(!s.empty()){
            auto up=upper_bound(s.begin(),s.end(),cost[i]);
            if(up!=s.end()){
                cur_money+=*up-cost[i];
                s.erase(up);
                s.insert(cost[i]);
            }
        }
        cur_money+=x;
    }
    return s.size();
}
int main(){
    int t;
    cin>>t;
    while(t--){
        int m,x;
        cin>>m>>x;
        vector<int> cost(m);
        for(int i=0;i<m;i++){
            cin>>cost[i];
        }
        cout<<func(cost,m,x)<<endl;
    }
    return 0;
}

  • »
    »
    12 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    You are removing the hapiness with cost just greater than the one you are inserting in else if(!s.empty()) condition.. you need to erase last element of s ie auto it=s.end(); s.erase(--it);

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

Can someone point out why this JAVA solution for problem C is getting TLE? solution_link

I have implemented it using HashMap and a similar solution written in C++ has got accepted.

»
12 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Here you go, an implementation for problem F :-

https://codeforces.com/contest/1974/submission/262012373

This required me custom camparator for std::set and good use of upper_bound() and erase() of std::set.

»
12 days ago, # |
  Vote: I like it -13 Vote: I do not like it

Dear Codeforces Team,

I want to address the issue regarding my solution (ID: 261392643) for problem 1973B, which has been flagged for similarity with many other submissions. I assure you that I did not share or receive code from anyone. Here's my explanation:

Independent Work: I wrote my solution independently and did not share it with others. Common Approach: The problem might have a common solution approach many programmers use, leading to similar code. No External Sharing: I did not use any public code-sharing platforms like ideone.com.

Additionally, my solution (ID: 261370439) for problem 1973A has been flagged without any issue or information. If needed, I can provide more details about my approach to solving the problem to demonstrate my independent work. I am committed to fair play and integrity in this competition.

Thank you for your understanding.

Best regards, redbear_

»
12 days ago, # |
  Vote: I like it +6 Vote: I do not like it

Just had a look at the problems and Kudos to the authors for constructing such a great problem-set. I absolutely loved the similarities/differences (and their implication) between problems E and G.

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

I wrote my code on ideone, and hence might have been the reason.If needed, I can provide more details about my approach to solving the problem to demonstrate my independent work. I am committed to fair play and integrity in this competition.

Thank you for your understanding.

»
11 days ago, # |
  Vote: I like it +5 Vote: I do not like it

hey MikeMirzayanov what is this partial behaviour towards flagging solutions.

This user -> looneyd_noob is out of competition for the solution: https://codeforces.com/contest/1974/submission/261894175 but i also noticed the solution of this user -> Shaxx19 who is not out of the solution even having a very similar solution just variable name changed and some comments added and even submitted 10 minutes later; this is his solution https://codeforces.com/contest/1974/submission/261900757 the entire nested for loop is same with same indentation. Man he needs to get out of contest, you are doing very wrong and people's trust will reduce from this platform. Please get him out of competition.

  • »
    »
    10 days ago, # ^ |
    Rev. 2   Vote: I like it -9 Vote: I do not like it

    I noticed that someone has raised concerns regarding the similarity between my solution and another user's solution, and is requesting my disqualification from the competition.

    I would like to clarify that my solution is indeed my own work. Any similarities to other submissions are purely coincidental, as the nature of coding often leads to similar logic and structures when solving the same problem. I have added proper comments to demonstrate my understanding of the code, which the other user hadn't.

»
10 days ago, # |
  Vote: I like it 0 Vote: I do not like it

I would like to ask who I should complain to if I find someone who submitted the same code as me in the competition. I want to cancel the score changes for both of us at the same time to ensure the fairness of the competition.

»
10 days ago, # |
  Vote: I like it +4 Vote: I do not like it

hey MikeMirzayanov what is this partial behaviour towards flagging solutions.

This user -> sjy is out of competition for the solution: https://codeforces.com/contest/1974/submission/261826313 but i also noticed the solution of this user -> frank11_sjy who is not out of the solution even having a very similar solution just variable name changed and some comments added and even submitted later; this is his solution https://codeforces.com/contest/1974/submission/261825867 the entire nested for loop is same with same indentation. Man he needs to get out of contest, you are doing very wrong and people's trust will reduce from this platform. Please get him out of competition.

  • »
    »
    10 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    yes there are various cases i noticed also like @sjy @rohan786 @frank11_sjy @kovi05007 who seem to have similar maybe they use ideone

    • »
      »
      »
      10 days ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Hope this is their first mistake, hope mike can cancel their div3 competition score and give a penalty warning

    • »
      »
      »
      10 days ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Bro, I want to ask if MikeMirzayanov will solve it if I complain here.

  • »
    »
    8 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    This kind of thing happened and I hope 945div3 doesn't give me a rating, but no one seems to care about this game anymore

»
9 days ago, # |
  Vote: I like it 0 Vote: I do not like it

my rating decreased to the rating that I got in the my 2nd last contest WHY ??

»
6 days ago, # |
  Vote: I like it 0 Vote: I do not like it

All of a sudden, my ratings got rolled back few hours ago! I wasn't notified of anything. The points just disappeared.

@MikeMirzayanov