pskobx's blog

By pskobx, 17 months ago, translation, In English

Hello! Codeforces Round 991 (Div. 3) will start at Dec/05/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. After open hacks all accepted solutions will be rejudged on successful hacks.

You will be given 6-8 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: AVdovin, DanGolov, kbats183, Vladosiya and pskobx.

We would like to thank:

  1. MikeMirzayanov for Polygon and Codeforces platforms.

  2. Vladosiya for coordination.

  3. EgorUlin, qsmcgogo, molney, misorin, vladmart, Blinov_Artemii for yellow testing.

  4. snasibov05, FBI for purple testing.

  5. artcosec, Pslnd, _icy_, Gabbasov, UniversalAdmin for blue testing.

  6. dmit_brit, WahidmShafin, Osama.Rafat100 for cyan testing.

  7. Kaushal_26 for green testing.

Good luck!

UPD: Editorial is out.

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

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

yay! Vladosiya round

»
17 months ago, hide # |
 
Vote: I like it -42 Vote: I do not like it

first comment :D

»
17 months ago, hide # |
 
Vote: I like it +26 Vote: I do not like it

As an author, I want to admit, that I am an e-girl...

»
17 months ago, hide # |
 
Vote: I like it -24 Vote: I do not like it

Tread on me plz!!!(♡▽♡)

»
17 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Capture

non-Notorious Coincidence

»
17 months ago, hide # |
Rev. 3  
Vote: I like it +14 Vote: I do not like it

If I don't become specialist after this round, I'll quit CP.

»
17 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Hoping that there are no interactives in this one

»
17 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Why are there so many yellows testing the round lmao

»
17 months ago, hide # |
 
Vote: I like it +19 Vote: I do not like it

As a green tester, problems are exciting. I recommend participating, and wish you good luck and have fun.

»
17 months ago, hide # |
 
Vote: I like it +9 Vote: I do not like it

xD

»
17 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

is it possible to get high rating without an anime PFP?

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

    no

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

      How do you practice codeforces?? I am grinding towards becoming Expert but stil struggle. Please help. Thanks!

      • »
        »
        »
        »
        17 months ago, hide # ^ |
         
        Vote: I like it +1 Vote: I do not like it

        i read a problem, and if i dont have an idea within 5 minutes i read the editorial and then try to understand where my thinking went wrong. this way of practicing is how i reached expert so quickly. hope this helps

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

          So you dont give too much time to ponder about the approach. Interesting. Thanks !..

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

            i believe that if i am truly able to solve the problem i will probably get the solution in about 10 minutes. and i dont think its worth it to struggle for hours just to be able to say that you solved without editorial. also often it happens that you just dont know a technique that is key to solving the problem, and i dont understand why i would bother if that is the case

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

          and how much time you devote a day and any specific number of problems you target daily??

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

I think that I can also participate officially :) I am an Expert with a 1600 rating now.

»
17 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

in div3 the number of problems u solve and how quickly u solve them matters? not which problem A or G u solved ? right ?

»
17 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Hopefully I can reach Expert after this round. Good luck for me and for everyone.

»
17 months ago, hide # |
 
Vote: I like it -8 Vote: I do not like it

is it rated for newbies?

»
17 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Hopefully I can reach Specialist after this round. Good luck for me and for everyone.

»
17 months ago, hide # |
 
Vote: I like it +27 Vote: I do not like it

StringForces

»
17 months ago, hide # |
Rev. 2  
Vote: I like it -37 Vote: I do not like it

This contest reminds me of the awoo comment about problems from which you learn nothing. I don’t know what I’ll learn from C and D.

»
17 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Why in the world are problems B and C, B and C?

»
17 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Problem C is a good Problem. I've learned something from it.

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

    I just did dp I assume there is another way around IDK yet so don't spoil it for me

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

      There is a "math" way to do it. At least that's what I did.

      • »
        »
        »
        »
        17 months ago, hide # ^ |
         
        Vote: I like it +1 Vote: I do not like it

        Say the original number modulo 9 equals p and there are n 2s and m 3s. Then we have 2*x + 6*y = 9 — p, where 0 <= x <= n % 9 and 0 <= y <= m % 9. So we can enumerate x to get the answer. Is this the "math" way you are talking about?

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

          Yeah, the idea is basically it.

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

          Can u pls elaborate more? I don't get why u use 2 & 6.

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

            $$$2*2 - 2 = 2$$$

            $$$3*3 - 3 = 6$$$

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

              I got Runtime error in TC 3. Is there anything I missed that u said? ~~~~~ string str; cin>>str;

              ll sz = str.size();
              
              ll sum=0;
              map<int,int>mp;
              for(ll i=0;i<sz;i++)
              {
                  sum+=(str[i]-'0');
                  mp[str[i]-'0']++;
              }
              
              if(sum%9==0)
              {
                  cout<<"YES"<<endl;
                  return;
              }
              
              ll num  = stoll(str);
              
              ll mod = num%9;
              
              ll x = mp[2];
              ll y = mp[3];
              
              ll mod1 = x%9;
              ll mod2 = y%9;
              
              for(ll i=0;i<=mod1;i++)
              {
                  for(ll j=0;j<=mod2;j++)
                  {
                      ll a = 2*i + 6*j;
              
                      if(a==9-mod)
                      {
                          cout<<"YES"<<endl;
                          return;
                      }
                      else if((sum+a)%9==0)
                      {
                          cout<<"YES"<<endl;
                          return;
                      }
                  }
              }
              
              cout<<"NO"<<endl;

              ~~~~~

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

                First of all, when you want to share a code share it like this

                Spoiler

                or like this 295180304

                You're probably getting an error because of this line

                ll num  = stoll(str);
                

                str has $$$10^5$$$ digits and c++ only allows 19 digits at most .

                i see you used num to calculate modulo 9 you can callculate the sum of digits modulo 9 instead

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

                  295219248

                  Actually IDK how to share code in comment. It's my first time.

                  I fixed how u said. Got WA in TC 3

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  17 months ago, hide # ^ |
                   
                  Vote: I like it 0 Vote: I do not like it
                  int mod1 = min(x % 9 + 9, x);
                  int mod2 = min(y % 9 + 9, y);
                  

                  This would work. 295266464

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

                  Or

                  int mod1 = min(x, 9LL);
                  int mod2 = min(y, 9LL);
                  

                  295267641

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

        295079165

        I tried the above using the property where sum of digits of number divisible by 9 -> number is divisible by 9, then applied the logic to increase the sum to a multiple of 9, but unsure why it fails test 3?

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

          The number can't fit in long long as it's length can be as high as 100000, you have to store it as a string.

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

            I see. Then would inputting in a string then summing up with a ll work?

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

              Yup, you can sum up the individual digits from the string and continue with the rest

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

I almost jumped to reroot dp for G.

»
17 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

I was close to AK this contest and it would be my first ever AKed contest, but I couldn't solve $$$F$$$ 😢

can anyone explain how to solve $$$F$$$ ?, thanks in advance ^_^

»
17 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Thank you very much for the round. Good problems. Will not be reaching Specialist I guess, that's the only sad part.

»
17 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

how to do D

  • »
    »
    17 months ago, hide # ^ |
    Rev. 4  
    Vote: I like it +3 Vote: I do not like it

    It is bruteforce. For any $$$i$$$ only the next $$$10$$$ numbers can take that place since others would get reduced to $$$0$$$ before it reaches $$$i$$$ th position.

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

problem b and c felt really weird

»
17 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

interesting tasks, thx

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

i think A and B were cool and appropriate for their positions, C was a bit too easy if you were able to get the solution quickly, and probably impossible otherwise. D was weird, but it has the same problem as C i think. E was a very educational dp for div3, and as someone who struggles with dp, i found it very fun. i dont think segment tree/sparse table should be included for div 3 contests(althought i might just be salty because i couldnt ak the contest because of those), so i think F was a bit misplaced. and G was amazing, and it was a ton of fun to solve. great contest overall, and i found it very fun to participate. :D

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

    I got the solution for C quickly and spent 1 hour in it bc of a missing "+9" b4 a %9 lmao

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

      can you explain c please.

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

        For a number to be divisible by 9, the sum of its digits has to be divisible by 9. The only digits you can change are 2 and 3. If you change 2, you add another 2 to the sum, and if you change 3, you add 6 to the sum. You can now iterate over the amount of 2s in the number, and for each fixed amount of 2s, calculate if there is a number of 3s that you can change so that you can get a number divisible by 9. Its actually sufficient to check if adding 0,1 or 2 3s is enough, since the sum%9 will be periodic after that. The complexity is O(cnt2), but it can be done in O(1) as well

»
17 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

My intuition for C is based on the divisibility rule of 9 ( if the sum of digits of the number is divisible by 9, then the number itself is divisible by 9). So If that is the case initially, we don't need to do any thing. Otherwise, we can only convert all 2s in the original number to 4 (+2 to the total sum) or convert all 3s in the original number to 9 (+6 to the total sum) or convert some of the 2s and some of the 3s and each time check if the resulting sum is divisible by 9.

»
17 months ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

Damnnn it was too easy...

»
17 months ago, hide # |
 
Vote: I like it +7 Vote: I do not like it

is it a string round?

»
17 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

I honestly did not enjoy the earlier problems being so implementation heavy. I had much more trouble doing A-E rather than F,G.

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

I do not know how I solved b. I guessed my way to AC. Can anyone please explain why this works? This is my submission 295089033.

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

    you can not transfer any amount between indices of opposite parity
    you can transfer any amount between any indices of same parity
    use above two facts to figure out solution.

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

      I am sorry I don't understand what you mean. Can you explain in a bit more detail please?

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

        assume there is a queue of alternating men and women
        a men can give money as well as take the money from any other men
        same goes for women
        let $$$M$$$ be the total money men's have and $$$W$$$ be the total money women's have
        so if average money for men ($$$\frac{M}{no \ of \ men}$$$) and women ($$$\frac{W}{no \ of \ women}$$$) is equal then answer is yes

»
17 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Can someone find the mistake in my below code for G?

https://mirror.codeforces.com/contest/2050/submission/295071112

»
17 months ago, hide # |
 
Vote: I like it +20 Vote: I do not like it

Perfect div3 doesn't exi.. Nevermind

»
17 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I think this is a speedforces. ABCDE — normal, but F is very easy on his place. I think, F maybe to move on D-place or E-place. G — cute task, but i cannot to debug my code....

»
17 months ago, hide # |
 
Vote: I like it +5 Vote: I do not like it

problems were very satisfying to solve. Great div3 despite being bit tougher than avg div3.

»
17 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I have a question who soled B. Did u guys seen this kind of problem before and that helped OR u came up with the solution in the contest?

  • »
    »
    17 months ago, hide # ^ |
     
    Vote: I like it +11 Vote: I do not like it

    Usually in these types of "applying operation" problems, it is useful to think of some invariant which will not change after applying the operations or changes in a more "simpler" way which is easy to tackle. For example, in this case, the sum at odd and even indices does not change.

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

      I thought of the whole array sum that will not change so the number at the end must be (sum/n) if sum%n !=0 print NO otherwise I convert each number from left to right to (sum/n) by doing the operation and then check the whole array

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

        You solved the problem for the case when the operation is applied on index i and i+1. Tweak it a little bit and you can get this one too.

»
17 months ago, hide # |
Rev. 6  
Vote: I like it 0 Vote: I do not like it

For G

5

2 1

3 1

4 3

5 2

Here if we remove vertex 2 and vertex 3 , we end up having 3 connected components , but the ans for this test case is 2. Where m i going wrong ?

»
17 months ago, hide # |
 
Vote: I like it +21 Vote: I do not like it

How unfortunate that problem F is literally the same as this problem: https://mirror.codeforces.com/problemset/problem/1549/D (P/S: I don't intend to criticize anyone because having the same idea as the old problems isn't rare, it is just that I really want to point this out)

»
17 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

During contest I got Idleness limit exceeded on test 1 verdict 295079719. That is weird because it's the first time I have that error on a non interactive problems. I think the problem is the case where n == 1, because the difference array will have length 0. But the more weirder thing is that it works on my local machine.

So my question, is it because the difference array is empty, or is there another problem with my sparseTable that cause the error?

»
17 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

what you guys think will be the rating distribution on the problems? B a little bit hard to be a 800/900 right?

»
17 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

G was best :)

Thank you for the problems

»
17 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it
void solve()
{
    string s = "1";
    string x;
    cin >> x;
    s+=x;
    int n = sz(s);
    for(int i=1;i<=n;i++)
    {
        int idx = i , maxi = s[i]-'0';

        for(int j=i+1;j<=min(j+9,n);j++)
        {
            int digit = s[j]-'0';
            digit-=(j-i);

            if(digit>maxi)
            {
                idx = j;
                maxi = digit;
            }
        }

        s[idx] = maxi + '0';

        while(idx-i>0)
        {
            swap(s[idx],s[idx-1]);
            idx--;
        }
    }

    string ans = s.substr(1,n);

    cout << ans << "\n";
}

for question D why this code give tle ? can someone tell ?

»
17 months ago, hide # |
 
Vote: I like it -6 Vote: I do not like it

StringForces???

»
17 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Problems of contest are so interesting also not pure math.I enjoyed

»
17 months ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

pskobx Vladosiya, the validator for D doesn't match the problem constraints. The problem doesn't specify that the given string must be a valid integer, but the validator denies strings like "01". The problem is about making lexicographically largest string, so it has no reason to be a valid integer by itself at all.

Validator 'V.exe' returns exit code 3 [FAIL Token parameter [name=s] equals to "01", does...9][0-9]{0,199999}" (test case 1, stdin, line 2)]

Although I can't see the full validator message I assume the full regex is about accepting valid integers only. I hope it gets changed.

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

    You're right, strings should be considered as strings here. All hacks with verdict "incorrect" will be rejudged soon.

    • »
      »
      »
      17 months ago, hide # ^ |
       
      Vote: I like it +7 Vote: I do not like it

      Thank you. Also maybe consider adding a test with several such cases?

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

        Actually, the Russian statement specifies that the string does not have leading zeroes, so the validator was designed to check this. In this case, we need to revert the validator to a stricter version and update the English statement accordingly.

»
17 months ago, hide # |
 
Vote: I like it -8 Vote: I do not like it

how so solve g? i think its dp but i dont know how to do it

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

    Notice that the value of (a,b) is just $$$(\sum\limits_{x\in Path(a,b)} deg_x-2)+2$$$.

»
17 months ago, hide # |
 
Vote: I like it +12 Vote: I do not like it

Look at the submissions by Dima393SF and cemenkovich_kloun. Them submissions are very equvalent. I think, they are cheating. Please, ban them.

Sorry, my English is very bad.

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

I hope participants like KMO will be banned cause solving A in 1 minute and C in 1 minute right after this is not impossible, it is hilarious considering the history of his participations in previous contests.

»
17 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

It took me 36 contests but I've finally reached Pupil. Let's go!!!

»
17 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Greatest div 3 of all times

»
17 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

What should be the difficulty level of E? I do not trust Clist.

»
17 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Ahh..so good to see so much progress!!

»
17 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

295391659

for problem C why is this giving WA on TC 3.