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

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

Hello, Codeforces!

I'm pleased to invite you to Codeforces Round 1028 (Div. 1) and Codeforces Round 1028 (Div. 2). It starts on May/31/2025 17:35 (Moscow time). This means that Children's Day will come during this round. I'm sure everyone will be impressed with Children's Day, even if they're no longer children.

I remember when I was a kid, I always looked forward to Children's Day. On Children's Day, there were always candies and fun activities at school. But as I grew up, this festive atmosphere was diluted by the trivialities of life. But luckily, we had Codeforces. Spending the holidays with interesting problems doesn't actually have to be more boring than candies and activities ¯\_(ツ)_/¯

This will be the second round I've hosted on Codeforces. To make it better, this time I've called on my friend MagicalFlower to help me organize this round. Also, errorgorn has helped us very much, we are fully indebted to this well known 🐸 on Codeforces!

For both divisions, you will have 2 hours to solve 6 problems. I hope you will enjoy these problems.

I would like to thank:

Especially, I'd like to thank JoesSR, zhaohaikun and ToxicPie9 for helping us prepare this round, which might not be able to run as smoothly as now without them.

Finally, I would like to give my heartfelt thanks and praise to errorgorn.

Both of the rounds I hosted would not have been possible without the support and efforts of errorgorn. Although he often rejected my problems 💀 and stood me up a lot 😡, I could sense his love for the problems and his seriousness about the competition in the time we spent together preparing for these rounds.

errorgorn is an interesting guy, you can often see him sending funny emoji like 🤯 in the discord, and he would also sometimes share me with some of the local culture of Singapore. I am so lucky to have had this fun time with him.

Some time ago, errorgorn happened to tell me that he might not have time to continue as Coordinator, which I deeply regretted. Likewise, I'm starting my college career, and this will probably be the last round I host at Codeforces as well.

Hopefully this round will be a perfect end to my experience hosting rounds on Codeforces. It's really quite an unforgettable experience, and I'm also looking forward to the next collaboration with errorgorn.

The main character of the problems will be Gellyfish🍏, and her friend Flower🌸.

Score distribution:

  • Div.1: $$$500-1250-1750-2250-3000-(2500-3500)$$$
  • Div.2: $$$500-750-1250-2000-2500-3000$$$

Good Luck & Have Fun! 🔥🔥🔥

UPD1: Congratulations to the winners!

first solves in Div.1
first solves in Div.2

UPD2: Editorial is out.

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

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

Sorry guys, errorgorn can't coordinate anymore. He's busy coordinating dates with me 😳

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

I aim to reach pupil in this round ,and solve at least 3 problems

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

As a tester, I hereby strongly recommend Frieren: Beyond Journey's End (葬送のフリーレン).

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

Hope to solve 3 questions for the first time in a div2.

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

This is my first contest as a specialist!

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

good luck

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

Appreciate the effort—looking forward to the contest!, and good luck with your college career.

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

Hoping that problems will be very easy

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

Hopefully it's going to be a fun game :D

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

Feeling your love for errorgorn — is this a record for 'how many times someone is mentioned in a round announcement'?

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

hope to solve three in 20-30 and then grind on 4th

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

As a tester,I think these problems are brilliant and I hope you find them enjoyable.

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

Whenever I try to use emoji, it says:
Emoji (and other unusual UTF-8 characters) are not supported :|

And this guy filled the blog with emojis.(¬_¬)

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

Use no emojis in these blogs.

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

hope to solve 3 problems and get +delta

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

hope to be green again!!

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

errorgorn is a interesting guy

a -> an

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

I'm literally 1 rating away from participating in Div 1 XD

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

It should be "is an interesting guy" ig, on the last 4th paragraph.

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

As a tester,I hope you enjoy this contest :)

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

It’s really sad to hear that this will be your last round as a coordinator =(( Thank you for all the effort and passion you’ve poured into preparing such fun and thoughtful problems. Even if you won’t be hosting rounds anymore, I hope you’ll stay connected with the Codeforces community in some way. Wishing you all the best in your next chapter!

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

Happy Children's Day ;-)

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

hope to solve 2 questions for the first time in Div-2

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

all the best to everyone

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

I will crashing the round gg

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

Hope to not get wrong on first 3 submission

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

I have been losing ratings in the past 3 rounds. Hopefully, this pattern will change today :)

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

I miss my childhood

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

I will never be a contester in any contests of THU qwq

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

Wasn't div2C/div1A a simple wrapper over https://mirror.codeforces.com/contest/1043/problem/F ?

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

Problem 2 can be done in O(n) ig, premax of indices and max of biggest index in p and q (also their respective index :( in case of equal)

»
11 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится +8 Проголосовать: не нравится

The time limit on C was surprisingly tight. Tried to do 2d caching for a while before I realized the second dimension was unnecessary.

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

Getting Destroyed by testcase 3 on problem D for an hour and a half crew. Fun problems, thanks!

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

WA on pretest 9 in C?

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

BurnedChicken What happened

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

what is that Div2B :"/

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

Glad I couldnt figure out A immediately and decided not to participate further :)

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

Could anyone kindly help explain why this solution isn't working(at test case 3) for problem B? TIA

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

long long power(long long base, long long exp, long long mod) {
    long long res = 1;
    base %= mod;
    while (exp > 0) {
        if (exp % 2 == 1) res = (res * base) % mod;
        base = (base * base) % mod;
        exp /= 2;
    }
    return res;
}

int main(){
    ll tt;
    cin>>tt;
    //tt=1;
    ll mod=998244353;
    while(tt--){
        ll n;
        cin>>n;
        ll p[n],q[n];
        for(ll i=0;i<n;i++){
            cin>>p[i];
        }
        for(ll i=0;i<n;i++){
            cin>>q[i];
        }
        ll up=0,down=0,upPos=0,downPos=0;
        pair<ll,ll>res[n];
        for(ll i=0;i<n;i++){
            if(p[i]>up){
                up=p[i];
                upPos=i;
            }
            if(q[i]>down){
                down=q[i];
                downPos=i;
            }
            if(up>down){
                res[i].first=up;
                res[i].second=q[i-upPos];
            }
            else if(up==down){
                res[i].first=up;
                res[i].second=max(q[i-upPos],p[i-downPos]);
            }
            else{
                res[i].first=p[i-downPos];
                res[i].second=down;
            }
        }
        for(ll i=0;i<n;i++){
            cout<<(ll)(power(2,res[i].first,mod)+power(2,res[i].second,mod))<<" ";
        }

        cout<<"\n";
    }

    return 0;
}
»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

div2C<<div2D

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

Submission

I think my solution to problem C is $$$O(n^3)$$$, why it can pass pretests?

UPD: Oh I got it, the time complexity is $$$O(n^2)\cdot \log{[\max(a_i)]}$$$.

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

you really telling me 5000*5000*log(5000) doesn't pass in div1A?? no comments

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

    You can precompute all GCD pairs up to $$$N - 1$$$ in $$$O(N^2)$$$ I think. You make a sieve like loop, where you iterate over numbers (results) $$$d$$$ and mark $$$GCD[i * d][j * d] = d$$$. The last time you substitute $$$GCD[i][j]$$$ will be for $$$d = gcd(i, j)$$$. You can avoid multiplication if you write it like this:

    vector<vector<int>> GCD(N, vector<int>(N, 1));
    for(int d = 2; d < N; ++d)
        for(int i = d; i < N; i += d)
            for(int j = d; j < N; j += d)
                GC[i][j] = d;
    

    Why is this $$$O(N^2)$$$? Because the number of substitutions is equal to $$$\sum (N / d)^2 \lt N^2 \zeta(2) = N^2 \pi^2 / 6 \sim 1.5 N^2$$$.

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

    mine passes though?

    322233494

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

      I forgot you can't see code few minutes after contest, so here.

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

    bfs (towards 1 / global gcd) turns out to be much faster
    (although I can't figure out the exact complexity in my head right now, can someone figure?)

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

Div2A>Div2B

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

Why so hard?

»
11 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится -6 Проголосовать: не нравится
Images

Find the difference

First TLE and second AC

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

Thanks for the nice contest!

Really, I was quite surprised by both the simplicity and difficulty of div1B/div2D. It's really easy to fall down the rabbit-hole of erroneous thought. I was only able to do it after using the technique "ok, instead of thinking in a straightforward manner, let's think in reverse (ie, bottom-up)". Once you start thinking that way, the problem becomes very straightforward and you realize that the solution is like 10 lines of code.

I wonder why I struggled so much with it... I guess for future reference, be more prepared to think in reverse?

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

    geez, I did thoughta about thinking in reverse immediately, but the solution is still not straightforward to me. So sad.

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

      If you want, I can give you the following hint:

      the hint
      • »
        »
        »
        »
        11 месяцев назад, скрыть # ^ |
         
        Проголосовать: нравится +5 Проголосовать: не нравится

        Kinda get it. Still it is quite intricate. Thx!

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

          I mean, the description is kinda scary, but really, the solution just ends up being:

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

    How is the solution straightforward when thinking in reverse?

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

Good problems but I took way too long to solve them :( Skill issue at work again.

How to solve $$$D$$$?

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

Can anyone tell me what is the pretest 9 of problem div2 C??

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

Why is time limit on 1A and 1C so tight? I was just optimising constant factor for most of the time on C, not fun at all. If O(n * m * H) is not supposed to pass set higher limits on them. If it is supposed to pass set lower limits.

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

Please Help How to Solve B?

I got wrong answer in tc3, got pounded by B today.

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

It was nonsense To prove my point, only 300 people were able to solve more than 3 questions

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

can someone please point out why this code failed on pretest 3 submission. thank you

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

How do you solve Div2C?

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

why frozen?

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

First time getting stuck on Problem B for so long. (why so hard contest)

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

Bro ,i understand your urge to provide great problems to us and honestly they were good as they were not constructive (upto C) as per me ,but i think B and C are hard as per their numbers.I don't know how so many people were able to solve C that too using BFS.This was definitely great contest to learn,but C was too hard and not trivial.

Anyways please recommend me some more problems like C ,i want to get over these type of problems.

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

Quite frustrating that linear complexity for 2B in Python was not enough :/

After 1 hour of bumping my head at it I cached the exponents of 2 as a global variable and got it passing on pretests.. Let's see what the final tests do.

»
11 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится +14 Проголосовать: не нравится

I think I had the biggest comeback in codeforces history today Solved question B in 1:50:18 Solved question C in 1:59:52 322287747 322294715

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

Got the idea for B correctly but for some reason pretests failed. Interesting problem. At one point I forgot they were permutations and considered 2 maximums.

Basically find the largest number and its index in P then 2^that number + corresponding in Q. The same with Q.

It'd be nice if C++ had modular exponention.

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

    I used the similar approach but it failed on pretest 3, waiting for the test case :(

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

    If you have two positive integers $$$P$$$ and $$$Q$$$, both $$$\leq 10^5$$$, you can proceed in the following way.

    Let's compute an array of all powers of $$$2$$$ modulo $$$MOD = 998244353$$$. You can do this with this piece of code:

    vector<ll> powers(N+5);
    powers[0] = 1;
    for(ll i = 1; i <= N; i++) powers[i] = (powers[i-1] * 2) % MOD;
    

    Now powers[i] stores $$$i$$$-th power of $$$2\,(mod\,998244353)$$$. You can now compute $$$2^P+2^Q\,(mod\, 998244353)$$$ as follows:

    (powers[P] + powers[Q]) % MOD
    
»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится +28 Проголосовать: не нравится

Div1C has a bit of the old Codeforces vibe.

»
11 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится +54 Проголосовать: не нравится

In 1A's DP. If I check if the dp[j]!=INF before updating dp[gcd(i, j)] I can got AC, but TLE on #7 if I didn't check it. And, my solution is $$$O(5000^2)$$$ by getting all 5000*5000 gcds before calculate the test cases. I can't understand why the time limit is unmeaningful tight.

Good Luck & Have Fun! [Fire][Fire][Fire]

Sorry, I never have a good luck and I can't have fun in this round, only the fire fit my emotion.

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

    I also had the concern about the constant factor of $$$5000^2$$$ GCD's, but luckily my solution passed, so I checked the difference between my solution and your first submission.

    It turned out:

    • If you implement GCD with recursion, it will timeout. Using std::gcd is OK.

    • During the DP, you should update dp[gcd__[a[i]][j]], not dp[gcd__[j][a[i]]]. It's due to the cache efficiency. gcd__[a[i]][j] is a contiguous memory access but gcd__[j][a[i]] is not.

    With the two fixes (and without DP[i][j]!=INF pruning) you can get AC (322321188). I first thought it's all about the speed of GCD but the second fix was also necessary to pass the test 7.

    I agree that the time limit is a bit tight. However, given that just updating dp[gcd(a[i],j)] was enough to get AC, it's understandable that author didn't see the necessity to increase the time limit.

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

      As I recently found out (and probably many people did but considered unimportant), there is a very easy way to $$$\gcd(i,j)$$$ for all $$$1 \le i,j \le n$$$ in $$$\mathcal{O}(n^2)$$$ time. The proof is a little mathematical though.

      Let $$$k$$$ be a candidate of $$$\gcd(i,j)$$$. Then, both $$$i$$$ and $$$j$$$ must be a multiple of $$$k$$$. Among all values that swept through $$$(i,j)$$$, the largest such value of $$$k$$$ must be the value of $$$\gcd(i,j)$$$. So perform a doubly nested loop inside the loop for $$$k=1\dots n$$$, analogously to any sieve-like algorithm that relies on the Harmonic Lemma.

      The time complexity. Let $$$\displaystyle f(n)=\sum_{k=1}^\infty {\frac{n^2}{k^2}}$$$. This becomes $$$\displaystyle n^2 \sum_{k=1}^\infty {\frac{1}{k^2}}$$$. The factor in the sum is known to converge, and due to the Riemann Zeta function we know that its value is $$$\zeta(2) = \pi ^2 / 6 \approx 1.65$$$. So our number of operations is bounded above by $$$1.65n^2$$$, meaning that we have an algorithm to preprocess all $$$\gcd$$$ in good time complexity and also great constants.

      The relevant submission, 322328173, passes in 234ms.

      EDIT: I just got notified that you can just simulate the Euclidean algorithm in DP to get $$$\mathcal{O}(n^2)$$$. That is true. Not having to rely on $$$\gcd(i,j)=\gcd(i,j-i)$$$ and still getting great constants is pretty cool though.

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

I used BFS in problem C but got wrong answer, was I thinking correct? I inserted initial array elements in the queue, with their turns marked as 0, then for every element polled from queue , lets call it c, I calculated its gcd with all the array element, and if the calculated gcd , call it x , is not in the queue I insert it with its turn been equal to turn[x]=turn[c]+1. Here turn represent number of operations needed to get down to x. Suppose g is the gcd of the whole array , then my answer is n-1+turns[g]. In special case when turn[g]==0, I will calculate count of g in array and answer would be n-count[g]. Let me know what I missed.

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

https://mirror.codeforces.com/contest/2115/submission/322293995

why does this TLE for Div1C? I'm pretty sure it's O(n*m*h), which should be comfortably AC.

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

322294608

can anyone tell me why my code was wrong at pretest 9 (div2C)

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

Amazing contest! But the time limit for Div2D and Div2C was very tight. My Div2C got TLE for 5000*5000. My O(nlogn) solution for D also got TLE cause I used too many maps. My mistake for not writing in an optimized way, still not having such a tight bound would have been great.

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

I got no idea to solve problem D :( ,is there some simple idea to tackle it ?

Also struggled a bit in understanding what is happening in A , but logic was not so difficult finally

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

Nice Chinese TLs, guys.

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

Very good round! D was super nice.

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

Div. 2 A Simple solution

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

The Div2C should have allowed n^2*log(5000) to pass

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

const ll MOD =998244353; long long binpow1(long long a, long long b, long long m) { a %= m; long long res = 1; while (b > 0) { if (b & 1) res = res * a % m; a = a * a % m; b >>= 1; } return res; } vector<ll> pow2(200005); void chill() { int n; cin>>n; vi p(n); take(p,n); vi q(n); take(q,n); vector<ll> r(n, 0); vi pp(n,0); vi qq(n,0); r[0] = (pow2[p[0]] + pow2[q[0]]) % MOD; for (int i=1;i<n;i++) { if(pow2[p[i]] > pow2[p[pp[i - 1]]]){ pp[i] = i; } else{ pp[i] = pp[i - 1]; } if (pow2[q[i]] > pow2[q[qq[i - 1]]]){ qq[i] = i; } else{ qq[i] = qq[i - 1]; } int ind1 = pp[i]; int ind2 = qq[i]; r[i] = max(r[i],(pow2[p[ind1]] + pow2[q[i - ind1]]) % MOD); r[i] = max(r[i],(pow2[p[i - ind2]] + pow2[q[ind2]]) % MOD); } for (auto &it : r){ cout << it << " "; } nl; } int main() { in_trice int times = 1; cin >> times; // cout<<times<<endl; for (int i = 0; i < 200005; ++i) { pow2[i] = binpow1(2, i, MOD); } for(int i=1;i<=times;i++){ chill(); } return 0; }

Can someone please tell me why this failed on testcase - 3 PROBLEM B

»
11 месяцев назад, скрыть # |
Rev. 3  
Проголосовать: нравится +53 Проголосовать: не нравится

I must have some crazy bug in B. I took away the check that it is possible to attain the answer with the min operation (so basically the check that at least a or b equals c where c = min(a, b)), and my solution somehow turned from WA to AC. What's interesting is my AC solution is very obviously wrong, since it doesn't output -1 on any tests like:

1

6 4

1 1 1 1 2 3

1 2 5

1 2 6

3 4 1

3 4 2

What is more interesting, my AC and WA solutions should differ only on tests of this type, and my AC solution somehow passes while being wrong on them, while my WA solution doesn't while being correct on them... Would be very thankful if someone could explain to me wtf is going on

»
11 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится +29 Проголосовать: не нравится

Are pretests for 1B too weak? My wrong attempt passed during the contest, but i realized it and fixed it afterwards.

Hope system tests get all wrong solutions WA.

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

    Also I was stucked in 1C for precision problems, since large combination numbers are needed.

    Don't know whether official solution requires it or not.

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

      No need for large numbers.

      Let’s denote $$$H = max(a_i)$$$. While there are at least two different numbers in the array, the optimal thing is to act greedily: reduce the maximum number if the sword doesn’t shine, and reduce all numbers otherwise (unless the minimum is already 1). If we fix the number of steps it will take for the “greedy part” to be over (i.e. all numbers are equal), it’s easy to calculate the probability of this happening: a dp where your state is $$$(a,b) =$$$ there are $$$a$$$ operations left in the greedy part (at most $$$m$$$), and we still need to apply $$$b$$$ non-shine operations ($$$b$$$ is initially equal to $$$\sum_{i=1}^{n}(a_i - \min(a_i))$$$, so at most $$$n*H$$$). Transitions are straightforward and this dp is $$$\mathcal{O}(m \cdot n \cdot H)$$$.

      Once all the numbers are equal, you can notice that you if you use the “non-shine” operation once in a number, you need to do it in all the others too (otherwise they will never be equal again). You can do a second dp where state is $$$(a,b,c) =$$$ there are $$$a$$$ operations left (at most $$$m$$$), we already used $$$b$$$ “shine” operations (at most $$$H$$$), and there are $$$c$$$ elements in the array (at most $$$n-1$$$) in which we reduced their value by one (if we reduce all the $$$n$$$ values by one, we increase $$$b$$$ by one and set $$$c$$$ to zero). Transitions are not too complicated neither.

      When fixing the number of operations in the first part, the initial state for the second part is fully determined. Both parts have the same complexity, so full solution is $$$\mathcal{O}(m \cdot n \cdot H)$$$, and there are no big numbers involved.

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

Very hard problems... The problems are way too hard to solve within the time in contest.

I don't think it's a good contest

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

whatt

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

Petition to set all round duration to 3h

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

too hard /_ \

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

How to solve Div2-B ?

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

    first , you need to notice that taking the greatest exponent will always result in a better answer, because it will be greater than the other ones by at least a factor of 2, so you will be tracking the prefix max on p and q . now for every index i , one exponent would be the biggest value in the prefixes of both p and q, now to get the other exponent you need some caseworking , basically if the biggest value was on the p side you need to get the index it was in (you can create the index arrays for both p and q ) and the other exponent will automatically be the q[i-(that index)], vice versa if the max was in q , now if the prefix maxes were equal in both p and q , you'll need to consider 2 cases , take the index of the max in p , take the index of the max in q , than the ans would be the max between p[i-(second index)] and q[i-(first index)] . and do that for all i to construct the answer

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

Div2 C's Time Limits are too tight,I don't think i like this problem

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

Someone who solved 2C using bfs,please explain me your approach and have you solved this kind of problem before and if yes and possible ,please link it.

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

Was there a faster solution for D1A? I ended up changing my code in fear of system tests (1.5s runtime / 2s) and it was still incredibly slow.

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

    my complexity was n * maximum * gcd computation ... it ran for 1.5s in pretests ... but it passed system test just now

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

    My solution is $$$O(N^2log(K) / log log(K))$$$ (where $$$K$$$ is $$$max \; A_i$$$) and it passes in 187ms: 322286852

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

anyone who was struck in 3rd testcase div2D, and then corrected the solution?

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

    yeah so for div2D my issue was with the backwards-walk logic. I had to split the cases more ((a, b) -> c, (a, b) -> b, (a, a) -> b, (a, a) -> a). And just a whole bunch of ifs regarding the lower-bounds and exact values

    the core idea is just propagating lower bounds for the values and then doing a recheck at the end

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

Getting TLE related to this: https://mirror.codeforces.com/blog/entry/97390

Why was i not able to correct my code during the contest? Other competitors got tle on test case 5 during contest and were able to make changes to get AC.

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

D2C had 15 pretests...mine was WA on 14 (╥﹏╥)

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

Couldn't figure out how to speed up B, any hint?


pot2 = [pow(2, x, 998244353) for x in range(100001)] for _ in range(int(input())): n = int(input()) P = list(map(int, input().split())) Q = list(map(int, input().split())) potP = [pot2[p] for p in P] potQ = [pot2[q] for q in Q] r = [] for i in range(n): mv = 0 for j in range(i+1): v = (potP[j] + potQ[i-j]) % 998244353 if v > mv: mv = v r.append(mv) print(*r)
»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится +10 Проголосовать: не нравится

My teacher once told me, "If the contest is organized by Chinese, don't participate. All their problems will be math-related." Today, I participated in the contest and became convinced that my teacher was right.

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

Why wouldn't you bound $$$m$$$ to $$$4000$$$ in D1C? Why does $$$100 \times 400 \times 4000$$$ pass? Why doesn't my solution pass then?

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

My solution for Div2C was a brute force, I want to make all the elements equal to the GCD of the array

I will try each time to get the minimum gcd until the minimum element in the array is equal to this gcd, finally count the number of elements that aren't equal to this gcd

code
»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится +18 Проголосовать: не нравится

minute of silence for those whom got TLE with $$$O(n^2 \log n)$$$ in C

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

Problem 2 was difficult!

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

Why was my first submission skipped?

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

    If you submit on a problem which got accepted, only the last submission counts, also you get -50 for resubmit and I think the score you get is less too. All previous submissions get skipped

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

Why frozen? I cant submit my code.

»
11 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится +37 Проголосовать: не нравится

thanks for the div2 C loved raging and almost wanting to end everything

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

Can anyone explain why my latest submission of C is counted, even though my previous submission is also AC. It should be other way around right?

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

Goofy ahh contest

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

Why is the standing still frozen?

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

That was a very tough contest, I never performed this badly. I think I will see a -100 delta. But anyway, thanks for the contest and the efforts to prepare those problems.

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

DIV2C/DIV1A should be re-evaluated with an adjusted time limit.

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

can anyone explain why for div2b this fails... x = (pow2[ma] + pow2[b[i — idA]]) % mod; y = (pow2[mb] + pow2[a[i — idB]]) % mod; cout << max(x, y) << " ";

note: ma is maximum prefix of vector a idA is the index of maxim prefix and the b names are just the reverse..the codes which have gotten ac they have compared these two only but with different if()else conditions then why is this code wrong

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

Can anyone provide a hint for C?

It seems like it has no pattern whatsoever.

  • »
    »
    11 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится +15 Проголосовать: не нравится
    Hint 1
    Hint 2
    Hint 3
»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How the same code for Div2 C sometimes getting accepted and sometimes giving TLE on TestCase 7??

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

    Can you please help the code i have submitted for div2b is same as ypur first submission why did it fail why it isnt simply max(ab,cd) as in your code

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

      Sure, Let's suppose the value of ab is greater than cd.

      Now when you are taking mod, then the value of ab might become smaller than cd, but in reality value of ab is greater than cd. Consider this example

      int ab = (binpow(2,44) + binpow(2,4))%mod; int bc = (binpow(2,30) + binpow(2,30))%mod;

      Here, binpow(2,x) means (2^x)%mod.

      After this step, the value of ab & bc are as follow: ab 125811513 bc 150994942

      Now, here you can see that in reality ab is greater than bc, but due to taking mod, it's value has become less. So, instead of calculating their values, we should just compare the powers of 2, which I have done in my next submission. I hope this helps.

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

i used bellman-ford DP to solve div2c

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

not really sure what learning did Div2 C really had, with tough time constraints, i mean like same dp solution which passes with int16, is meant to TLE on TC 7 if u use long long by default in ur template, seriously??

Long long solution fails: https://mirror.codeforces.com/contest/2116/submission/322307127

int16 solution (above solution when done with int16) passes: https://mirror.codeforces.com/contest/2116/submission/322308744

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

those who wa on test 3 because of mod in div2b

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

https://mirror.codeforces.com/contest/2116/submission/322315881 In Div2C why is it giving tle on using long long and got accepted when used int..

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

    Well, your solution has a really huge constant factor due to using a deep recursion (2.5e7) and self-written recursive gcd function. It is known that using long long type increases time of arithmetic operations(including computing a reminder, which is necessary for gcd). It is very likely that this is why you get TLE. Rewrite you dp in iterative way, use std::gcd (which is written not recursively, but iteratively -> faster) and you will get AC with both long long and int. Here you can also invent some funny optimizations, like pre-compute all gcds for all pairs of numbers <= 5000. but they are 100% redundant.

    UPD: it seems like I wasn't correct at all, probably the only way to pass a solution is to precompute these gcds. The takeaway is : you should use #define int long long carefully when dealing with problems with tough TL or ML.

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

Why is there no rating change dor div 1

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

My solution for 2C passes with int (1.5s) but TLEs with long long :*)

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

Goodluck to all. someday i hope to participate in div 2

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

I realize I should learn to skip challenging problems earlier in future contests. During the competition, I spent 1 hour and 20 minutes struggling with Problem C. However, when I reviewed Problem E after the contest ended, I managed to solve it in just one hour! This experience has taught me the importance of adjusting my time allocation strategy during coding competitions.

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

Is there any glitch in system testing? My submission for div2 C was accepted during contest, failed on test 7 in system testing. Now when I submit the exact same code, it is getting accepted. Was hoping for a positive delta but missed because of this :)

Gellyfish any explanation — or anything that can be done about it? A rejudge would be appreciated

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

I think Div1-C has weak test cases. Many submitted codes can be hacked (time limit) with the following case:

t=100
1 4000 50
400
(repeated 100 times)
»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Why am I getting "unexpected error" when I attempt to submit for 2116A - Gellyfish and Tricolor Pansy and 2116B - Gellyfish and Baby's Breath?

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

my code gets AC on div2-D,but i think it is fake;how to hack it?https://mirror.codeforces.com/contest/2116/submission/322329033

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

Hey Gellyfish can we get a rejudge? I got A/C in contest for C on my first submission, and now got rejudged to TLE. You've got people who have 5+ failed submissions that later got A/C, this is unfair to the contestants that got a false A/C during the contest with no chance to correct this error. My ranking went from Top 500 to ~4,000 for a silly judging error

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

    Is it possible that this is because although the theoretical time complexity of your code meets the problem's requirements, the constant factor is too large? It's normal for the judging system to have some fluctuations.

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

      Yeah, in my case i used std::set for dp states, which barely passes (or fails) vs std::unordered_set with my exact same code passes with time to spare.

      It's just BS that people who got 5+ failed submissions rocketed past me in the standings and i had no chance to correct my code. I solved the problem relatively easily in around 10 minutes understanding the time complexity and got accepted on first submission.

      My projected rating post contest was supposed to be 1750, instead i ended up back at specialist. Spent 1:30 mins on problem D, if i had known there was any chance of code failing on C i could have easily corrected it within this time. Trash judging IMO

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

can anyone tell me where to find editorial of this contest

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

Becoming one of the winners of Div.2 for the first time and become a Candidate Master!

The question is very interesting, but I didn't finish 2F in the end.

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

May I inquire if there are any official tutorials, and when they will be released?

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

Normally, Codeforces updates ratings and releases tutorials 2-3 hours after the system test. Why is this round so slow? Are there any issues with Codeforces?

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

First reach CM!

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

.

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

Hey, Can anyone look into mycode for Problem B Div2, It is failing for test 3.Not sure why it is failing and able to figure where went wrong.Help me on this.

Your code here...

# Online Python compiler (interpreter) to run Python online.
# Write Python 3 code in this online editor and run it.
mod = 998244353
for k in range(int(input())):
     n = int(input())
     a = list(map(int, input().split()))
     b = list(map(int, input().split()))
     r = []
     ma1 = [-1,-1]
     ma2 = [-1,-1]
     for i in range(n):
        if a[i]>ma1[0]:
             ma1[0] = a[i]
             ma1[1] = i
        if b[i]>ma2[0]:
             ma2[0] = b[i]
             ma2[1] = i
        r.append(max(pow(2,ma1[0],mod)+pow(2,b[i-ma1[1]],mod),
                 pow(2,ma2[0],mod)+pow(2,a[i-ma2[1]],mod)))
        r[i] = r[i]%mod
     print(*r)
         
     
»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
ll binpow(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1){
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b>>=1;
    }
    return ans%mod;
}

void solve(){
    ll n; cin>>n;
    vector<ll>a(n,-1),b(n,-1);
    for(auto &x:a){
        cin>>x;
    }    
    for(auto &x:b){
        cin>>x;
    }
    set<pair<ll,ll>>st1,st2;
    vector<ll>ans;
    for(ll i=0;i<n;i++){
        st1.insert({a[i],i});
        st2.insert({b[i],i});
        ll topbestidx=st1.rbegin()->second;
        ll belowbestidx=st2.rbegin()->second;
        ll maxi1=(binpow(2,a[topbestidx])+binpow(2,b[(i-topbestidx+n)%n]))%mod;
        ll maxi2=(binpow(2,a[(i-belowbestidx+n)%n])+binpow(2,b[belowbestidx]))%mod;
        ans.push_back(max(maxi1,maxi2));
    }
    for(auto &x:ans){
        cout<<x<<" ";
    }
    cout<<na;
}

where am i going wrong in qn B?

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

Can someone help me understand how the first solution is getting TLE. And, Even if it is getting TLE than how just that small change make the second solution pass

322340728

322341080

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

thanks for fast edtior

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

Oh I only solved 1 problem in Div.1. It's too hard T_T

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

I couldn't come with a DP solution for the Div2C, so I choose greedy method and it worked for me. When the GCD is not present in the array, I greedily keep on choosing the pairs which will give the least GCD, so first I scanned through all the pairs and then checked the pair with smallest no to every other no in the array. https://mirror.codeforces.com/contest/2116/submission/322288935

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

Please post editorial fast

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

when editorial

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

I am getting WA on TC-3. Please point out where i m going wrong..

322358648

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

why so many downvotes ? that was an interesting contest. thank you for the round

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

unpopular opinion: I've enjoyed the contest.

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

DIV 2, PROBLEM C, PRETEST 9

Input: 50 numbers... My Answer: 50 Given Answer: 53

My approach: I found the GCD of all the 50 numbers, which is 1. So there necessarily exists a co-prime pair in the 50 elements.

So, my first operation will be on this co-prime pair, which will give me 1. Now, for the remaining 49 elements, i will pair them with 1, one by one, and hence obtain all the ones.

In this way my total operations will be 50.

Please tell me where i went wrong?

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

Since there's no editorial yet, F has super low number of solutions even now but it seems

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

Although D1C was really hard for me, still it's quite nice to finally reach gm

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

Where is the solution of 2C?

  • »
    »
    11 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится
    #include <bits/stdc++.h>
    using namespace std;
    
    const int N = 5001;
    const int INF = 1e5;
    int g[N][N];
    
    void solve()
    {
        int n, cur_gcd = 0, cnt = 0, maxi = 0;
        cin >> n;
        vector<int> a(n);
        for (auto &v : a)
        {
            cin >> v;
            cur_gcd = g[cur_gcd][v];
            maxi = max(v, maxi);
        }
    
        for (auto &v : a)
            cnt += (v == cur_gcd);
    
        if (cnt > 0)
        {
            cout << n - cnt << "\n";
            return;
        }
        vector<vector<int>> dp(maxi + 1, vector<int>(n + 1, -1));
        for (int i = 1; i <= maxi; i++)
            dp[i][n] = INF;
        dp[cur_gcd][n] = 0;
        for (int j = n - 1; j >= 0; j--)
            for (int i = 1; i <= maxi; i++)
                dp[i][j] = min(dp[i][j + 1], 1 + dp[g[i][a[j]]][j + 1]);
    
        int ans = INF;
        for (int i = 0; i < n; i++)
            ans = min(ans, n - 1 + dp[a[i]][0]);
        cout << ans << "\n";
    }
    
    signed main()
    {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        cout.tie(nullptr);
    
        for (int i = 1; i < N; i++)
            g[i][0] = g[0][i] = g[i][i] = i;
    
        for (int i = 1; i < N; i++)
            for (int j = 1; j < i; j++)
                g[i][j] = g[j][i] = g[j][i % j];
    
        int T = 1;
        cin >> T;
        while (T--)
            solve();
    }
    
»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Is it too hard to post editorial for this contest?

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

Hi everyone Can anyone tell me where is my Folse in DiV2 Problem B pleas make loke in the code Thanks[submission:322445331]

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

Why so many downvotes? I think it's a great contest with themes.

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

Whether there is a communication group of learners, I have a lot of questions to know.

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

Hi, my submissions for this round has been skipped! this is the message I got

Your solution 322239991 for the problem 2116C significantly coincides with solutions Prady/322211648, Siddarth_MSR/322229699, mehul1512/322239991, Rafat_Kabir/322252055, AlterAB/322290280.

However, the coinciding code is already published on GeekForGeeks- link

pls upvote so I dont lose rating:(

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

Hi

My submission to the problem 2115C has been skipped due to similarity with some other submissions. However, that is because I had used a code snippet from GeeksForGeeks, published before the commencement of the round. Here is the link:

https://www.geeksforgeeks.org/minimum-length-of-subsequence-having-unit-gcd/

As it can be clearly seen, the article was published in 2023.

Please look into it Gellyfish errorgorn

Thanks!

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

Below is a concise justification focusing on why nearly every correct 2116D solution follows the same template (hence the similarity is not plagiarism):


Why all correct solutions “coincide”

  1. 1. Segment‐tree for “last writer.”
  • We must know, for each final index i, which operation (or leaf) last wrote to i. The only efficient way (in O(log n)) is a segment tree that, at operation i (node u = n+i), does

    ``` childA = seg.get(xᵢ);

    childB = seg.get(yᵢ);

    left[u] = childA; right[u] = childB;

    seg.set(zᵢ, u);

    ```

    After all updates, owner[i] = seg.get(i). Every solver uses this same approach (or a DSU variant that amounts to the same).

  1. 2. Build the dependency tree.
  • Leaves 1…n represent original a-positions; internal nodes n+1…n+q represent the q “min” operations. For each u=n+i, we already recorded left[u] and right[u]. That gives exactly two‐child edges “u = min(left[u], right[u])”. No other structure captures “c[zᵢ] = min(c[xᵢ], c[yᵢ])” correctly.
  1. 3. Backward propagation of final values.
  • If node u is “top” (i.e. it produced some final b[j]), then min(value[left[u]], value[right[u]]) must equal b[j]. So both children need ≥ b[j]. Recursively push need[child] = max(need[child], b[j]) down to leaves. There is simply no alternative: you must reverse‐propagate all b’s to find minimal a[i].
  1. 4. Forward evaluation/verification.
  • Once each node u has need[u], iterate u=1…n+q in order:

    ```

    if (u ≤ n) value[u] = need[u];

    else value[u] = min(value[left[u]], value[right[u]]);

    if (u is top and value[u] != need[u]) fail;

    ```

  • If all top‐nodes match, output value[1..n]; otherwise “–1.” No one found a different way to confirm min(child1,child2) == need[u] other than computing it directly.

Because this four‐step method is essentially the only correct, O((n+q) log n) algorithm for “reverse c[z]=min(c[x],c[y]) to reach b,” everyone’s code ends up with the same segment-tree calls, the same left[]/right[] arrays, and the same backward/forward loops. The near-identical structure is simply the standard template—found in CP-Algorithms, GeeksforGeeks, and many CF editorials—not evidence of copying from another contestant.

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

My solution for problem 2116A was flagged for coincidence with UltraMate/322220362. I want to clarify that I wrote the code completely on my own during the contest and did not share it with anyone. I did not use any public code-sharing platforms like Ideone. The problem had a straightforward logic, and it’s possible that similar ideas led to similar implementations unintentionally. I kindly request the admins to review my case and consider that I had no intention to violate the rules. I will be more cautious in the future. Thank you for your understanding.

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

Handle: ankitaSingh0036

I want to sincerely apologize for violating the contest rules regarding Problem 2116B. The solution I submitted (322272186) was not my own work. During a screen-sharing session, I saw code written by harshitjain without their knowledge or consent and submitted a similar solution as my own. They were completely unaware, and I take full responsibility.

This was a serious lapse in judgment. I understand the importance of fair competition and deeply regret my actions. I accept any consequences for this violation and assure you it will not happen again.

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

Handle: harshitjain

I received a notification regarding code similarity for Problem 2116B (submission ID: 322274436). I want to clarify that I wrote my solution independently in Visual Studio Code during the contest.

I was not aware that my screen was being viewed during a screen-sharing session, and I did not give anyone permission to use or copy my code. I did not collaborate with any other participant and was completely unaware that my solution had been accessed in this way.

The other user (ankitaSingh0036) has already admitted to copying the solution and accepted full responsibility. I respectfully request the Codeforces team to consider this explanation and their confession in your review, as I have not violated any contest rules.

Thank you for your time and understanding. here is the code that i wrote in vs code #include <bits/stdc++.h> using namespace std;

const long long MOD = 998244353;

long long power(long long x, long long y, long long mod) { long long res = 1; x %= mod; while (y > 0) { if (y % 2 == 1) res = (res * x) % mod; x = (x * x) % mod; y /= 2; } return res; }

long long getSum(long long x, long long y) { long long p1 = power(2, x, MOD); long long p2 = power(2, y, MOD); return (p1 + p2) % MOD; }

void solve() { int n; cin >> n; vector arr1(n); for(int i = 0 ; i < n ; i++) cin >> arr1[i]; vector arr2(n); for(int i = 0 ; i < n ; i++) cin >> arr2[i];

vector<int> res(n , 0);
int mx1 = -1 , mx2 = -1;
int idx1 = -1 , idx2 = -1;
for(int i = 0 ; i < n ; i++){
    if (arr1[i] > mx1){
        mx1 = arr1[i];
        idx1 = i;
    }
    if (arr2[i] > mx2){
        mx2 = arr2[i];
        idx2 = i;
    }

    int diff1 = i - idx1;
    int diff2 = i - idx2;
    int x1 = max(arr1[idx1] , arr2[diff1]);
    int x2 = min(arr1[idx1] , arr2[diff1]);

    int y1 = max(arr2[idx2] , arr1[diff2]);
    int y2 = min(arr2[idx2] , arr1[diff2]);

    if (x1 > y1){
        res[i] = getSum(x1 , x2);
    } else if (x1 < y1){
        res[i] = getSum(y2 , y1);
    } else {
        if (x2 > y2){
            res[i] = getSum(x1 , x2);
        } else {
            res[i] = getSum(y2 , y1);
        }
    }
}

for(int i = 0 ; i < n ; i++){
    cout << res[i] << ' ';
}cout << endl;

}

int main() { ios::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) solve(); return 0; } In my solution for Problem 2116B, I observed that for each position i, we need to compute a value based on some combination of elements from the two arrays. I realized that the result depends heavily on the larger elements encountered so far in both arrays.

To efficiently handle this, I kept track of the maximum elements seen so far in both arr1 and arr2, along with their indices (idx1, idx2). For each position i, I calculated:

diff1 = i — idx1 and diff2 = i — idx2 to reference a potentially better value from the other array at a certain offset.

Then, I took the maximum and minimum of these two values to form a meaningful pair.

The core insight I used was that:

The power of 2 grows exponentially, so the larger number in the pair will dominate the result.

That's why I focused on comparing the larger elements (x1, y1) from both strategies first.

Only if these were equal, I compared the smaller elements (x2, y2) as a tiebreaker.

Finally, I used a helper function getSum(x, y) to compute 2^x + 2^y % MOD, which ensures both correctness and efficiency under large constraints using modular exponentiation.

This logic allowed me to efficiently determine the best combination for each index and build the result accordingly.

Please look into it @Gellyfish @errorgorn

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

Hello,

My submissions for the round got skipped because of similarity with some other submissions on problem 2116C. Your solution 322229699 for the problem 2116C significantly coincides with solutions Prady/322211648, Siddarth_MSR/322229699, mehul1512/322239991, Rafat_Kabir/322252055, AlterAB/322290280.

However, that is because I had used a code snippet from GeeksForGeeks, which was published before the round started. This is the gfg link: https://www.geeksforgeeks.org/minimum-length-of-subsequence-having-unit-gcd/

Please look into it Gellyfish errorgorn

Thanks.

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

Handle: @harshitjain
Submission ID: 322274436
Contest: Codeforces Round 1028 div 2

I would like to respectfully clarify the reason for the similarity between my solution and that of @ankitaSingh0036 for Problem 2116B.

I wrote and submitted my solution independently using VS Code locally, and I did not upload or share my code on any public platform such as Ideone, Pastebin, or GitHub. However, during a screen-sharing session for unrelated reasons, another participant was able to view my code without my consent and submitted a similar solution. I was unaware that my screen was being monitored in a way that allowed this.

The user @ankitaSingh0036 has already acknowledged that they copied from me without permission. Their message states:

"I want to sincerely apologize for violating the contest rules regarding Problem 2116B. The solution I submitted (322272186) was not my own work. During a screen-sharing session, I saw code written by @harshitjain without their knowledge or consent and submitted a similar solution as my own. They were completely unaware, and I take full responsibility."

I understand the importance of Codeforces’ anti-plagiarism policy and acknowledge that unintentional leakage is also taken seriously. However, I had no intent to share my code or violate any rules.

I respectfully request that my submission be reconsidered, and my rating change be restored. Thank you for your time and fair evaluation.

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

Hi Handle: @harshitjain Submission ID: 322274436 Contest: Codeforces Round 1028

I wrote my solution independently using VS Code locally and did not share it publicly. During a screen-sharing session, another user (@ankitaSingh0036) viewed my code without my consent and submitted a similar solution. They have accepted full responsibility for this.

I had no intention to violate any rules and kindly request reconsideration of my submission.

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

Dear Codeforces Team,

I recently received a message regarding a significant coincidence detected in my solution (Submission ID: 322252055) for Problem 2116C in Codeforces Round 1028 (Div. 2). The message indicated a potential rules violation due to similarity with other participants’ submissions. The message I received was:

"Your solution 322252055 for the problem 2116C significantly coincides with solutions Prady/322211648, Siddarth_MSR/322229699, mehul1512/322239991, Rafat_Kabir/322252055, AlterAB/322290280."

However, that is because I had used a code snippet from GeeksForGeeks, published more than 2 years before the commencement of the round. Here is the link: Minimum length of subsequence having unit GCD.

Clearly, according to the post regarding Third-party code by MikeMirzayanov,

Solutions and test generators can only use source code completely written by you, with the following two exceptions: 1.the code was written and **published/distributed before** the start of the round.

Please have a look into this Gellyfish errorgorn MikeMirzayanov.

Thanks!

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

why in test case 1 in C div1(Gellyfish and Eternal Violet) is said "Otherwise, if the sword does not shine in the first round, she will attack monster 1 in the first round. For the second round:" how about Gellyfish choose not to attack