Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

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

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

Hello Codeforces!

flamestorm, MikeMirzayanov and I want to invite you to Codeforces Round 898 (Div. 4).

It starts on 21.09.2023 17:35 (Московское время).

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 behaviour. 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.

Many thanks to the testers: Gheal, Phantom_Performer, KrowSavcik, haochenkang, sandry24, BucketPotato, Vladosiya, NintsiChkhaidze, erekle, Dominater069, MADE_IN_HEAVEN, Qualified.

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

Good Luck!

UPD: Editorial is out!

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

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

monthly leetcode contest let's gooooo!!! hope the statements are clear to everyone (so that we can ak faster)

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

So hapy for the round. I did't participate in a rated round for a long time.:)

P.S. I am not racist

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

My first unrating contest :)

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

As a tester, today K77 will score a goal. P.S problems are very nice.

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

Why?

  • Why isn't Division 4 prepared on a weekly or bi-weekly
    basis instead of being held every two months?
class vote:
    votes=0
    def __init__(self,state="up"):
        if state=="up":
            votes+=1
        else:
            votes-=1
upvote_me = int(input())
for i in range(upvote_me):
    obj = vote(state="up")

print(vote.votes) 

upvote pls ``)

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

Where is SlavicG ?

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

This contest is gonna be fun!

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

First unrated contest for me !!

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

its been ages since the last time problem ratings were updated. :feelsoldman:

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

My First Unrated Round

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

Specialist here I come!!!

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

Hopefully my last rated div4 :O

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

Finally First unrated contest

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

Bro really I was waiting for this day to participate in my first Div 4. contest and I can not register because of one rating point

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

is it rated?

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

    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.

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

i am going to participate despite having chemistry exam tomorrow, sorry to mr Ratherford, Bohr, Thomson, Schrodinger, Higenberg and 69 others :)

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

Good luck to everyone, I hope I can get specialist this round!

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

average div4 round

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

Cool problem set.

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

balanced problems and clear statements, this is defintion of a perfect contest!! thanks to the authors

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

Loved the Kendrick Lamar references throughout the contest! The authors have good taste in music

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

WTF IS WRONG WITH PROBLEM F?

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

    I see nothing wrong with F. Time wise, it took me much longer to solve G.

                   problem: A  B  C  D  E  F  G  H
      num_minutes_to_solve: 6  2 10  3  5 26 63 28
    
»
12 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

bruh imagine doing 5 problems in 18 minutes and being like top 50 or even better and then taking 2 hours for the sixth one, i don't understand what happened to my brain :((((((

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

    Same. But I stuck at problem E. Did anyone give some advises for solving binary search problems like this? I am too dumb to ensure the edge condition. Would I use mid = (l+r)/2 or(l+r+1)/2? give answer as l? or r? or mid? all gives me a lot trouble.

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

      C#, but should be almost exactly the same in C++

       static long BinSearch(Predicate<long> IsInRightPart, long l, long r, bool firstYes = true)
              {
                  while (l < r)
                      (l, r) = firstYes
                          ? (IsInRightPart((l + r) / 2)
                              ? (l, (l + r) / 2)
                              : ((l + r) / 2 + 1, r))
                          : (IsInRightPart((l + r + 1) / 2)
                              ? (l, (l + r + 1) / 2 - 1)
                              : ((l + r + 1) / 2, r));
                  return l;
              }
      
»
12 месяцев назад, # |
Rev. 3   Проголосовать: нравится 0 Проголосовать: не нравится

why is this code wrong for E? plz give me some advice. thx in advance.

include <bits/stdc++.h>

using namespace std;

long long num[200001]; long long dp[200001];

int main(void) { ios::sync_with_stdio(0); cin.tie(0);

int t;
cin >> t;
for(int i=0; i<t; i++)
{
    int n, x;
    cin >> n >> x;
    for(int j=0; j<n; j++)
       cin >> num[j];
    sort(num, num+n);
    dp[0] = num[0];
    for(int j=1; j<n; j++)
       dp[j] = dp[j-1] + num[j];
    long long st = 0, en = 4000000001;

    while(st+1 < en)
    {
       long long mid = (st+en)/2;
       long long tmp = lower_bound(num, num+n, mid) - num;
       if(tmp == n)
         tmp--;
       long long gap = mid*(tmp+1) - dp[tmp];
       if(gap > x)
         en = mid;
       else
         st = mid;
    }
    cout << st << '\n';
}

}

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

    (not verified with code but just based on code review): The raw tmp value range is [0,n] and then adjusted to [0,n-1]. When tmp is 0, gap should be 0 instead. To fix, do not adjust tmp, but compute gap with:

      gap = mid * tmp - (tmp == 0 ? 0 : dp[tmp-1]);
    
»
12 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

please explain F

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

Duuuudeeee if I had like 1 minute, I would've solved the last problem yikes

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

include<iostream> #include<bits/stdc++.h> using namespace std; int possible(vector<int> v,int mid){ int n = v.size(); int wdth = 0; for(int i=0;i<n;i++){ if(v[i]<mid){ wdth = wdth + (mid-v[i]); } else{ continue; } } return wdth; } int main(){ int t; cin>>t; while(t--){ int n; cin>>n; int w; cin>>w; vector<int> v; for(int i=0;i<n;i++){ int x; cin>>x; v.push_back(x); } int low = 1; int high = w + accumulate(v.begin(),v.end(),0); int ans = -1; // binary search on heights while(low<=high){ int mid = low + (high-low)/2; if(possible(v,mid)<=w){ low = mid + 1; int cnt = mid; ans = max(cnt,ans); } else{ high = mid - 1; } } cout<<ans<<endl; } }

i applied checked width for every height from lower to upper bound and applied binary search on heights it passed 3 test cases whats the problem ?

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

Why showing penalty currently in the standings? I didn't do wrong submissions?

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

    penalty is total of time you need to get AC all problems. If you haven't AC a problem (except WA on test 1), then 10 minutes is added to your penalty when you AC that problem.

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

pwild can you please explain this beautiful solution of yours for G?

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

    Imagine the character 'B' will divide $$$s$$$ into some parts of consecutive 'A'. Then the answer is just the total 'A' in $$$s$$$ minus the minimum number of 'A' among all these parts.

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

    zackscott286 already explained what the code does. To get there, note that we can get rid of any sequence of 'A' as long as there is a 'B' next to it, but that a single 'B' can only be used to eliminate either the sequence to its left or the one to its right. As the number of 'A' sequences is one more than the number of 'B', one of the 'A' sequences needs to stay, and we can always ensure that we only keep the shortest. The maybe somewhat surprising part of this is that this still works if this shortest sequence is empty, i.e. if the string starts or ends with 'B' or contains a substring 'BB'.

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

MY INTUTION FOR THE LAST ONE IS. ONLY ONCE CYCLE EXISTS IN THE GRAPH IF IT DOES. FIND WHERE THE PERSON RUNNING CAN ENTER IT. THEN SEE WHO CAN REACH IT FIRST. IF THE PERSON RUNNING CAN REACH IT FIRST ITS A YES OR ELSE A NO. AM I RIGHT? I COULD NOT DO IT COZ I WENT TO EAT A CAKE.

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

When you've spent a whole hour coming up with a solution for H when there are 1 to n*(n-1) edges, and only after the solution was found do you notice that there are only 1 to n edges =|

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

Problem E is nice, came up with binary search fast but spent lots of time fixing the high bound, lesson learned for me.

Problem G is so nice, with short and clear statement, like it the best in this contest!

Thank you guys for the contest!

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

For problem F: Given, (l≤i<r). Here, How l and r can be same? That means (l==r)?

Please explain some one...

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

Can someone help me find issue in F? I am not finding any case where it is failing. TIA https://mirror.codeforces.com/contest/1873/submission/224511926

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

Does problem F, test 2, test case 1: n = 2, k = 15, a = {9, 6}, h = {1, 3} exists a contiguous subarray satisfies the condition that each i (l <= i < r), h_i is divisible by h_(i+1)? The expected answer is 1, but there is no h_i is divisible by h_(i+1), so I think there is no contiguous subarray satisfies the condition. Please explain.

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

For Problem E how are we supposed to fix the upper bound while using binary search

I never thought upper bounds could be an issue. I assumed taking high bound as LLONG_MAX-1 should suffice always

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

I was surprised by my friend's submission in problem E. He used greedy that I couldn't think it was possible LOL. His submission: 224456152

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

Nice contest! I really enjoy it

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

Were some of the problems in the contest inspired by Kendrick lamar?

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

Please try to hack this Problem F

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

Some of the problem names reference Kendrick's songs, right?

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

In queueueueueueueueueueueue!!!

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

My first cf contest!!! For a freshman.

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

Kendrick Round

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

    it may be only a coincidence.

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

    Another coincidence with Luogu Monthly Contest... Hope that the authors can check their problems in Chinese websites (such as Luogu) before the round in the future.

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

You can also watch the video editorials I made on the problems E , F, G and H

Enjoy watching and let me know what you think about them!

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

I'm sorry for using ideone.com

Supposedly, out of the five that I solved, it's showing (that Solution B) of mine coincides with a couple of people, in a hurry while submitting I accidentally used ideone.com with public display settings, Sorry for that

Proof: https://drive.google.com/file/d/17RVpgMSCirhaVRcfAAACe9_cnKEhVPLd/view?usp=sharing

Sorry :/

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

I want to clarify that the similarity between my solution (224380982) for problem 1873C and the solution by Anonymous_P (224476541) was purely coincidental and occurred due to the unintentional public access of my code on onecompiler.com (which I had no idea about). My submission, under the username redder02, was made at 20:37, while Anonymous_P's submission was at 22:07, clearly indicating that my code was posted well before theirs. I take the rules seriously and request you to consider this timeframe in your evaluation.

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

Прилетело мне страшное письмо. Якобы я списал или у меня списали решение задачи 1873C. Мое решение 224347406, чужое — 224380578. Решения, действительно, очень похожи. Но по сути они оба совпадают с авторским, а их структура является стандартной для решений на python. Собственно, как теперь доказать, что я не верблюд?

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

Okay so got a message from system that my solution got coincided with the solution of some other person whom I do not know at all My solution: https://mirror.codeforces.com/contest/1873/submission/224426160

The other one: https://mirror.codeforces.com/contest/1873/submission/224487303

The only thing seems similar in the codes is the logic that is checking the conditions updating the variable neither do I use any platform where my solution can get leaked nor do I know the other person. It was just a pure coincidence since the solution was simple. Kindly review it.

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

well in the third problem "Target Practice" the output is wrong.

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

Can anyone please find any exception for my source code for G? I think my code is correct but it gets wrong on test 2. My submission: 246793693.