awoo's blog

By awoo, history, 10 months ago, translation, In English

Neapolis University Pafos

Hello Codeforces!

The series of Educational Rounds continues thanks to the support of the Neapolis University Pafos. They offer a BSc in Computer Science and AI with JetBrains Scholarships. Gain cutting-edge skills in AI and machine learning, preparing you for high-demand tech careers. Limited scholarships available — don't miss your chance to study in Europe for free!

On Jul/22/2025 17:35 (Moscow time) Educational Codeforces Round 181 (Rated for Div. 2) will start.

This round will be rated for the participants with rating lower than 2100. It will be held on extended ICPC rules. The penalty for each incorrect submission until the submission with a full solution is 10 minutes. After the end of the contest, you will have 12 hours to hack any solution you want. You will have access to copy any solution and test it locally.

You will be given 6 or 7 problems and 2 hours to solve them.

The problems were invented and prepared by Adilbek adedalic Dalabaev, Ivan BledDest Androsov, Maksim Neon Mescheryakov, Maksim FelixArg Novotochinov, Polina ifive Piklyaeva and me. Also, huge thanks to Mike MikeMirzayanov Mirzayanov for great systems Polygon and Codeforces.

Big thanks to the testers shnirelman and Brovko for their valuable advice and suggestions!

Good luck to all the participants!

UPD: Editorial is out

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

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

I hope to get specialist in this contest, I have a high hope for it. And, BTW, is online class for the university avialiable?

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

The CSAI curriculum link leads to a deleted file.

»
10 months ago, hide # |
Rev. 3  
Vote: I like it -42 Vote: I do not like it

As a tester, i recommend!

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

i have very bad track record with edu,hoping to get positive delta in this contest!

»
10 months ago, hide # |
 
Vote: I like it +6 Vote: I do not like it

I hope it goes well

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

I hope after this round I feel some confident

»
10 months ago, hide # |
 
Vote: I like it +48 Vote: I do not like it

pls postpone this contest by 2 hours I have doctor appointment

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

less go. another edu round :fire

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

why does all the edu rounds are authored by awoo and BledDest ??

and Neon too

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

another edu, hoping to get back to pupil

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

Is this competition has open hack?

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

i love edu round

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

Good luck to myself and all of you!

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

I hope I become pupil in this round!

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

I hope to educate in this round

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

As an unrated participant, good luck to all rated participants.

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

Div 2 haha

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

Again! gonna get down! :(

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

I love edu round in CF as like as messi in football :v

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

what about score distribution ?

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

i hope this contenst doesnt ->()(->)-> ->()(->)-> ->()(->)-> ->()(->)-> ->()(->)-> me

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

Hi everyone, could someone explain the differences between educational and regular contests?

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

    +1

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

    The educational round is more educational, so the questions will be more skewed towards classic algorithms and classic routines, and the quality of the questions will be higher. Finally, there is no hack session in the educational round, and the ranking will be based on the penalty time instead of the score of the questions.

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

ahhhh. bad experience for me. Cause swap n,m, I took about 30-40 min on debug. Wish less mistakes on next round.

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

GPTForces. Brutal, people who can't even solve A on their own are getting (A-C) now.

This will also screw up the problem ratings. Problems that would have been legitimate 1500-1700 will now be considered 1100-1200 due to these AI scammers.

Seems like all the cheaters that got banned from Leetcode have migrated here because they have worse cheat detection

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

    atleast CF has divisions, because of it, we can expect minimal no. of cheaters in DIV 1 rounds.

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

      it used to be competing in div1 was worse for your rating because of tougher competition. Now it's better for your rating because div2 is flooded with cheats.

      Interesting anecdote: in leetcode contests usually around 50% of competitors get pruned due to cheating, so if you place 1000th or so you'll usually end up around 500th. Codeforces doesn't even prune 1%. There's Zero cheat detection.

»
10 months ago, hide # |
 
Vote: I like it +24 Vote: I do not like it

AiForces

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

i think this round should be renamed to "Math & Combinatorics Round"

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

    I hate contests with only single topic of tasks :((((( MathForces :(((((

    (i am angry because i bad at maths lol)

»
10 months ago, hide # |
 
Vote: I like it +15 Vote: I do not like it

E made my head hurt; What's the solution?

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

    First observation : you can always take an array a with 1 in it and all other element are unique (you add 1's to shift the min),

    Then you have just to count f(y) the number of n distinct elements (the smallest being 1) with sum y for all y<=x+1, and the final number is sum (x+1-y)f(y),

    f(y) can be computed with a classical dp similar to knap sack in O(xn) and n=O(sqrt(x))

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

      How can I compute f(y) for all y <= x+1 in O(xn)?

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

        The idea is to tranform that in a sum of coin problem

        $$$1=a_1 \lt a_2 \lt a_3 \lt ... a_n$$$

        $$$\sum a_i=y$$$

        let $$$d_i=a_{i+1}-a_i-1$$$, $$$y=n(n+1)/2+\sum (n-i) d_i$$$ so you wan to compute the number of way y-n(n+1)/2 can be expressed as sum of integer $$$\leq n-1$$$, iterate over this numbers and update dp in linear time

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

          I did reduce it to this sub-problem but couldn’t solve it. It seems like the kind of sub-problem that one would encounter frequently but I haven’t seen it before somehow.

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

          Thanks you

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

          Got it. So we are incrementing suffixes and $$$d_i$$$ is the number of times we increment $$$i^{th}$$$ suffix. When we increment a suffix, we add (size of the suffix) to the sum. And we start from $$$a = $$${$$$1, 2, 3, ..., n$$$}

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

MathForces :)

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

for E i figured out n<500, any more hints?

»
10 months ago, hide # |
 
Vote: I like it +49 Vote: I do not like it

No way these many people solved problem D, I suspect AI.

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

Master finally! Thanks for great problems (especially E)!

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

C got me bad

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

I misread D as Your task is to calculate the probability that each cell is covered by at least one segment. instead of Your task is to calculate the probability that each cell is covered by exactly one segment.and wasted more than 1 hour:(( still happy because after a long time I will get positive delta in Edu

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

    I solved the problem completely and it was my first time solving a dp problem! The only thing I didn't understand properly was the last explanation and how to submit the answer. This really bothered me.

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

      The last explanation is just telling you to do all your computations modulo 998244353. You just have to use %998244353 after each sum or multiplication you do and know how to calculate the modular multiplitcative inverse (you can find it here).

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

    I had the same issue, i think that it is written poorly is to say the least if not even wrong at all.

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

主播主播,这比赛很nb但还是太吃操作了,有没有那种即不吃操作又能上分的比赛 Streamer, this game is awesome, but it's still too skill-intensive. Are there any games that are neither skill-intensive nor hard to rank up in?

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

in problem 2,,,,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~

include <bits/stdc++.h>

using namespace std;

int main() { int ;cin>>; while(_--){ int a,b,k; cin>>a>>b>>k; for(int i=2; i<=k; i++){ if(a<k && b<k){cout<< 1 <<endl;break;} else if(a/i <= k && b/i <= k && a%i==0 && b%i==0){cout<< 1 <<endl; break;} else{ cout<< 2 <<endl; break; } } }

}

~~~~~~~~~~~~~~~~~~~~~~~~ Why did this went wrong?

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

    This should use "<=": if(a<k && b<k){

    Consider a = 11, b = 3, k = 11

    Also, you should not loop up to k, b/c k can be up to 10^18. Instead, find the gcd of a and b, and check a/gcd <= k and b/gcd <= k.

    Consider a = 12, b = 18, k = 3: gcd = 6 a/gcd = 2 b/gcd = 3

    By using 2 and 3, you travel "diagonally" to (0, 0).

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

      Can you explain why GCD ? please.

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

        Taking the GCD will make sure that both coordinates are divisible by the same base step. So when we choose (dx, dy) = (a/g, b/g), we form a step that aligns perfectly with both axes — meaning the robot can reach the origin using just this one operation type. Now, regarding the cost: The first time you use (dx, dy) costs 1 All subsequent uses of the same operation are free So the total cost is simply 1, as we only introduce one unique operation. When these (dx,dy) steps are somewhat greater than k , you can just use (dx,dy) = (1,1) , until the value at 1 axis becomes 0 and then use (0,non_zero) or (non_zero,0) as (dx,dy) for 1 more coin , which will cost a total of two coins.

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

        because gcd(a,b) divides a and b perfectly so that we can use pair(a/gcd(a,b),b/gcd(a,b)) multiple times and which cost only 1.

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

        You want to find the smallest numbers such that you can move “diagonally” to (0,0).

        For a = 12, b = 18. You could get to (0, 0) using either dx = 4, dy = 6 OR dx = 2, dy = 3. This is because a/dx = b/dy, so an and b shrink proportionally as you perform operations. Now notice that the optimal pair is dx = 2, dy = 3 b/c it allows k to be smaller, k=5 wouldn’t work with dx = 4, dy = 6.

        Now you want to find the smallest dx, dy such that one number (which is a/dx or b/dy) can be multiplied to them to reach a and b. Because you want to minimize dx, dy, that means you want to maximize that number, which is why use the gcd

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

    you can't do loop in this question think other logic

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

I was stuck with second question. Trying to conjur some way to get the minimum number of operations. After trying and failing for long. I had an ephiphany that other than a particular edge cases everything can be achieved with 2 operations. I had a feeling, I couldn't prove but as I already give 3 incorrect submissions. I tried and it passed. Not sure if this is good or bad.

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

    The pressure of having WA that too multiple times is enough to frustrate you. If you still found the mental strength to give it another shot and submit even with 3 WA, it was all worth it. After all in the end you are competing against your own mind too.

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

    Just keep trying (1 , 1) and when one of them becomes 0 you can use (1 , 0) or (0 , 1) And with just these two you can reach (0 , 0)

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

How to E?

»
10 months ago, hide # |
 
Vote: I like it -19 Vote: I do not like it

E is definitely NTT

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

    How? I didn't use any algorithms except dp.

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

      Yes, I know it can be done with dp, because constraints are a bit small, $$$O(n \cdot x)$$$ dp works because of the check $$$(n - 1) + \frac{n \cdot (n - 1)}{2} \gt x$$$, we immediately return 0, so your worst case complexity is $$$O(x \cdot sqrt(x))$$$ right? I just did it in $$$O(x \cdot log(x))$$$

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

    What is NTT? Could you please elaborate on your approach?

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

      He was making a joke, probably based on problem A, where the problem statement says: a contest is difficult if it contains "FFT" or "NTT" as a contiguous substring.

      The joke here is that FTT and NTT (which stand for Fast Fourier Transform and Number Theoretic Transform, respectively) are advanced algorithms that may be used to solve difficult programming challenges. However, you won't encounter these in Division 2 level problems, and problem E isn't solvable with FFT/NTT.

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

from D to E is always hard to me

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

    I defined dp[i] as the probability that cells 1 to i are fully and uniquely covered. So for each segment ending at i, we add dp[l-1] * (p/q) * Π(1 — p_j/q_j) over all other segments ending at i. correct?

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

      You also probably should take into account that you want ALL other segments to be off (basically at the start we have Π(1 — p_j/q_j))

»
10 months ago, hide # |
 
Vote: I like it +25 Vote: I do not like it

ABCD was posted on youtube 20 mins after the contest started, how am I supposed to compete?

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

I'm unable to figure out the issue in my code for D. Since contest is over, I didn't make any submission since it was failing test cases so I'll add it as context at the end.

Approach: Made a graph connecting r to l-1 with edge cost p/q (using modinv). Recursion is:

rec[i] += rec[j-1]*prob, where prob is choosing interval (j,i) with its probability and all other intervals ending at i are not chosen. So product of all 1-c, where c is edge cost, multiplied with cost of (j,i) divide the complement.

Not sure if the inverse handling is wrong, or the probability math, the recursion etc. It would be great some one could help debug this.

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
using ii = pair<int,int>;

int p = 998244353; // mp prime
vector<vector<ii>> g; // making a graph
int dp[200100];

int binpow(int a, int b){
    if(b==0) return 1;
    int res = 1;
    while(b){
        if(b&1) res = res*a%p;
        a = a*a%p;
        b>>=1;
    }

    return res;
}

int modinv(int n){
    return binpow(n,p-2);
}

int rec(int node){
    if(node==0) return 1; // base case

    if(dp[node]!=-1) return dp[node];

    int ans = 0;
    int cum_prob = 1;

    for(auto &pp: g[node]){
        int c = pp.first;
        int v = pp.second;
        cum_prob = cum_prob*((1-c+p)%p)%p;
    }

    for(auto &pp: g[node]){
        int c = pp.first;
        int v = pp.second;
        int prob = (cum_prob*c%p)*modinv((1-c+p)%p);
        ans = (ans + (prob*rec(v)%p))%p;
    }

    return dp[node] = ans;
}

void solve(){
    // Write solution here
    int n,m;
    cin >> n >> m;
    g.resize(m+1);
    memset(dp,-1,sizeof(dp));
    for(int i = 0;i<n;i++){
        int l,r,a,b;
        cin >> l >> r >> a >> b;
        g[r].push_back({a*modinv(b)%p, l-1}); // r connects to l-1 as r to l totally covered using edgw cost of p/q
    }

    cout << rec(m);
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    solve();
}

Should have named variables better in retrospect...

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

Can someone link me the technique needed to do C? I dont know how to handle duplicate numbers that are divided by multiple primes less than 10

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

how to C?

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

    simply consider 16 cases...

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

      :skull:

      Rephrased to make it less scary for people.

      We've to subtract the multiples of subsets of {2, 3, 5, 7} from all available numbers

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

    A relatively straightforward solution:

    First, we observe that we only need to implement the function count(x), which calculates how many good numbers are less than or equal to x. The final answer is simply count(r) - count(l - 1).

    Another key observation: A number N is good if none of the primes 2, 3, 5, or 7 divide it. Since the least common multiple (LCM) of these primes is 210, the problem exhibits a cyclic pattern. This means the distribution of good numbers in the interval [1, 210] is identical to that in [211, 420], and so on.

    Let M be the number of good numbers in [1, 210]. We can then break down count(x) into two parts:
    1. The first part is (x // 210) * M, representing the number of good numbers in complete 210-number cycles.
    2. The second part counts the good numbers in the partial cycle (x - x % 210, x]. Since this interval has at most 210 numbers, we can compute this efficiently using brute force.

    The final result is simply the sum of these two parts.

»
10 months ago, hide # |
 
Vote: I like it +35 Vote: I do not like it

Why over 4,000 D solves? I thought it was a pretty challenging problem to figure out, and you're telling me there are hundreds of newbies and pupils who get the DP trick and correctly implement the modulo in <1hour?

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

    I defined dp[i] as the probability that cells 1 to i are fully and uniquely covered. So for each segment ending at i, we add dp[l-1] * (p/q) * Π(1 — p_j/q_j) over all other segments ending at i. correct?

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

      Looks roughly right. I used a different DP (cells from i to end are fully covered) but if correctly implemented this should work. Don't quote me on that, though

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

    Codeforces has no cheat detection. I thought C was pretty challenging with a tricky inclusion/exclusion and it has 12,000+ solves with tons of newbies and pupils. I had gotten expert and held for 10+ contests, but will now be back to pupil after this contest due to cheaters

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

      I don't get why everybody used inclu/exclu for C. Just... find the closest multiples of 2*3*5*7=210 to l & r? You only need to check for divisibility by four numbers, after all.

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

        I solved using Inclusion Exclusion as well. Can you share the 210 multiples approach. All I can understand is that gcd(x, 210) > 1 then 'x' has to be removed. How can we calculate that?

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

          Find the smallest l2 >= l and r2 <= r such that both l2 and r2 are multiples of 210. If l2 > r2 then you can just brute force since the gap is small, otherwise bruteforce l to l2 and r2 to r and add (r2-l2)/210*48 to the answer (there are 48 numbers from 210 to 420, 420 to 630, etc. that satisfy the properties)

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

        The window trick is definitely clever, but i don't necessarily think it's any easier to implement or discover.

        In other words, that doesn't convince me that C is any easier lol

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

          I mean, it's pretty trivial to implement imo? Solved in 10min by doing

          ll l2 = 210*(l/210);
          if (l2 < l) l2 += 210;
          ll r2 = 210*(r/210);
          

          and copy-pasting 3 brute force loops.

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

            Inclusion/exclusion is pretty trivial to implement as well, but I think discovering the solution is the hard part.

            AI gives the solution and any donkey can implement it

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

              C is a very very standard problem taught in India preparing for competitive exams for clgs. I am sure in other places also it is taught in PnC very likely. (I think that's why also it was solved using inclusion exclusion method by most)

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

    dp wasn't too hard But I don't think that many beginners (including myself) know how to measure.

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

    I had a vague idea it was gonna be dp but had no idea how to implement it & I didnt get the gist of modulo at all, can you help me with what that meant?

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

    I died on the modulo implementation. Knew how to solve the problem in floats but the modulo implementation was too hard to debug :/

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

made a stupid mistake in A, acted so dumb in C tryna find a sieve method until i had a good look at the range and realized there was a super easy way :c and i was dumbfounded at D and E cus what are thoseeeee

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

12k people for C is crazy, so much AI used

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

Can F be solved with lambda?

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

    Yes it can be!

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

      Would you mind elaborating on this?

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

        Sure thing!

        First of all, let's find current number of occurences of "docker" in string $$$s$$$, let's call that $$$occ$$$. We can create from $$$0$$$ to $$$\lfloor \frac{n}{6} \rfloor$$$ occurences. Next let's find lowerbound and upperbound of the number of occurences, that we need to create. Because after each replacement the number of occurences changes at most by 1, we only need to reach either lowerbound or upperbound. Reaching lowerbound is trivial, let's focus on reaching the upperbound.

        let $$$c_i$$$ be the cost of making the substring that ends at position $$$i$$$ equal to "docker". Then I want to pick $$$upperbound$$$ indices, such that the distance between adjacent is at least 6 and the sum of picked $$$c_i$$$ is minimal. Let $$$f(k)$$$ be the minimal sum of $$$c_i$$$ if I pick $$$k$$$ indices. Turns ouf $$$f(k)$$$ is convex, so lambda optimization is applicable. If I want to pick some number of indides, the dp for that is trivial.

        I am interested in the proof of convexity of $$$f(k)$$$.

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

          Quick question about this idea. Suppose we have a test case where we need to have X occurences of the string "docker". What happens in the case where we're doing the binary search on the value of lambda and find that:

          • For a lambda value o Y, the dp will use X + 1 occurences of the string "docker"
          • For a lambda value of Y + 1, the dp will use X — 1 occurences of the string "docker"

          That is, there is no integer value for lambda where the dp will use the exact amount of occurences of the string "docker". In cases such as these, how can I find the optimal value for lambda to calculate the answer?

          Just asking because I always thought you had to implement this idea with the value of lambda being a real number (instead of integer), but I noticed you implemented this idea with integers and I'm not sure why it works.

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

            If the function $$$f(k)$$$ is strictly convex (i.e. $$$f(k) - f(k - 1) \lt f(k + 1) - f(k)$$$), then such a thing won't happen. However in most cases the function isn't strictly convex, i.e. only $$$f(k) - f(k - 1) \le f(k + 1) - f(k)$$$ holds.

            Then there's still an optimal whole lambda for each $$$k$$$, but for some values $$$k$$$ it coincides. Why is it an integer? Consider lines $$$f(k) + \lambda k$$$ and $$$f(k + 1) + \lambda (k + 1)$$$. They intersect at the point $$$\lambda$$$, where

            $$$f(k) + \lambda k = f(k + 1) + \lambda (k + 1)$$$

            which can be written as

            $$$\lambda = f(k) - f(k + 1)$$$, which is an integer (if function $$$f(k)$$$ returns integers)

            That way each pair of adjacent lines intersect at an integer $$$\lambda$$$

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

              I never would have been able to think of this, so elegant. Thanks you so much for the help!

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

** I completed 4 tasks in 22 minutes, and I have a -13. Before 37 minutes I can't send tasks. ((((((

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

sooo many math problems!!!!

»
10 months ago, hide # |
 
Vote: I like it +33 Vote: I do not like it

Here's my solution to problem C. Let the Hate come.

code
  • »
    »
    10 months ago, hide # ^ |
     
    Vote: I like it +4 Vote: I do not like it

    orz

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

    So my initial approach was to do figure out sieve to keep track of primes because I found a pattern where every prime number increments the answer by 1. Like for 2,11 the answer was 1, for 2,13 was 2 and 2,17 was 3. So I would have answer for any range in the format [2,N].

    Then I started looking for distribution based prime counting functions to get a O(1) but couldn't get the correct answer.

    Then I figured, okay. I can just rid of all numbers that are divided by 2,3,5 and 7. Every thing else would have a factor greater than 9 and it would naturally include prime factors. But I also need to keep the common divisions so I don't discard the counts twice. Like for 6. It would be discarded twice because of 2 and 3. So I would like to keep 6 back.

    So I came up with -2, -3, -5, -7, +6, +10, +14, +15, +21, +35.

    ButI don't understand why everyone is doing 210 at the end (to remove multiples of 10 and 21?) But if so why stop at 210? You can keep going at it indefinitely?

    • »
      »
      »
      10 months ago, hide # ^ |
      Rev. 2  
      Vote: I like it 0 Vote: I do not like it
      • get all numbers between l and r (r-l+1).
      • subtract all cases of numbers div by 2,3,5,7.
      • add all cases of 2*3,2*5,2*7,3*5,3*7,5*7.
      • subtract all cases of 2*3*5, 3*5*7, 5*7*2, 7*2*3.
      • add all cases of 2*3*5*7 (210).

      ALL Of this Gymnastics done to avoid double-counting of cases (both in addition and subtraction)

      Ofc there are better ways to do it. (Just check out any solution by a specialist+ ig)

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

    The solution was hilarious in itself then I read your name. Epic!!

»
10 months ago, hide # |
 
Vote: I like it +14 Vote: I do not like it

I enjoyed the round however I find it a bit of a speedforces one. The statements we concise and clear which is commendable. Also loved the number theory theme behind most problems.

  • A. Probably one of my quickest As, immediately figured that we can sort the string.
  • B. Cute and balanced somewhat number theory problem.
  • C. Here I think that the C problem could've been more complex. The current version is probably too easy for C.
  • D. It could've been a C problem, a bit too straightforward for D.
  • E. Couldn't figure the idea till the end. Judging from myself and the number of ACs the gap between D is too huge.

Overall, a good educational round. Great job!

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

Man why was this contest time only 2 Hr instead of 2:15. I literally solved D just when the contest time completed :(. Today when i needed that extra time didn't get it :( . Please keep the contest time as 2:15 as before.

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

After submitting 3 in 1h, finding myself in 7k+ position!!! The AI force is ruining the contests. Isn't there any way to detect these?

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

    Honestly the same for me. I completed all 3 in 1 hour and when I saw the number of solves I felt so dumb but with the number of cheaters that we are seeing now a days I knew no point thinking too much about it.

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

    just dont measure your success with a stupid rating i literally solved 3 questions in 22 mins and ended up ~5k ish

    5k people solved D is still insane to me

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

      lol why are people downvoting !!!

      He's right, the amount of cheaters have increased insanely. I miss those days without AI.

      Now the ratings are not legit at all.

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

Can someone explain why most implementations for D not considering the probability $$$ 1 - \frac{p}{q} $$$? (or at least it seems so?)

What I did was for each suffix, calculate the probability of not taking segments and for a segment $$$ [l, r] $$$ we need to consider those probabilities in $$$ [l, r] $$$ divided by the notTake probability of current range. Let this value be $$$ bad $$$. Then $$$ dp_l = bad * \frac{p}{q} * dp_{r+1} $$$ over all segments starting at $$$ l$$$

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

    You need to calculate the following:

    $$$\sum_{S}{(\prod_{i \in S}{(\frac{p_i}{q_i})} \cdot \prod_{i \notin S}{(1 - \frac{p_i}{q_i})})}$$$,

    where $$$S$$$ is a set of segments that covers the whole strip with no overlaps.

    You can think of $$$\prod_{i \notin S}{(1 - \frac{p_i}{q_i})}$$$ as $$$\frac{\prod_{i}{(1 - \frac{p_i}{q_i})}}{\prod_{i \in S}{(1 - \frac{p_i}{q_i})}}$$$.

    Now let $$$G$$$ denote $$$\prod_{i}{(1 - \frac{p_i}{q_i})}$$$, you get that the original sum we needed to calculate is basically $$$G \cdot \sum_{S}{(\prod_{i \in S}{\frac{\frac{p_i}{q_i}}{1 - \frac{p_i}{q_i}}})}$$$.

    It seems like we have introduced a new $$$1 - \frac{p}{q}$$$, but this one is better since now the whole product is about one single set.

    • »
      »
      »
      10 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it
      #include <bits/stdc++.h>
      using namespace std;
      #define LL long long
      #define int LL
      #define VVI vector<vector<int>>
      #define VI vector<int>
      #define PB push_back
      const int M = 998244353;
      
      int powl(int a, int b){
          if(b==0) return 1;
          if(b==1) return a;
          int ans = powl(a, b/2);
          ans=(ans*ans)%M;
          if(b&1) ans=(ans*a)%M;
          return ans;
      }
      
      int inv(int a){
          return powl(a, M-2);
      }
      
      void solve(
              int i, int m, vector<int> &cs,
              vector<vector<int>>& all, map<int, vector<int>> &posns,
              vector<pair<int, int>> &ans){
          int n = all.size();
          if(i==m+1){
              int num{1}, den{1};
              int j = 0;
              for(int i = 0;i<n;i++){
                  if(j<cs.size() && cs[j]==i){
                      num*=all[i][2]; den*=all[i][3];
                      // int g = gcd(num, den);
                      // num/=g; den/=g;
                  }else{
                      num*=all[i][3] - all[i][2]; den*=all[i][3];
                      // int g = gcd(num, den);
                      // num/=g; den/=g;
                  }
              }
              ans.push_back({num, den});
          }
          for(auto j: posns[i]){
              int cst = i; int ce = all[j][1];
              cs.push_back(j);
              solve(ce+1, m, cs, all, posns, ans);
              cs.pop_back();
          }
      }
      
      signed main(){
          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
          #ifndef ONLINE_JUDGE
              freopen("in.txt", "r", stdin);
              freopen("out.txt", "w", stdout);
          #endif
          int n, m; cin>>n>>m;
          vector<vector<int>> all(n, vector<int>(4));
          map<int, vector<int>> posns;
          for(int i = 0;i<n;i++){
              cin>>all[i][0]>>all[i][1]>>all[i][2]>>all[i][3];
              posns[all[i][0]].push_back(i);
          }
          vector<int> cs;
          vector<pair<int, int>> ans;
          solve(1, m, cs, all, posns, ans);
          // for(auto &i: ans) 
          //     cout<<i.first<<' '<<i.second<<'\n';
          if(ans.size()==0){
              cout<<0;
              return 0;
          }
          int ans_num{0}, ans_den{ans[0].second};
          for(auto i: ans) ans_num+=i.first;
          int g = gcd(ans_num, ans_den);
          ans_num/=g; ans_den/=g;
          int f = ans_num;
          f=(f*inv(ans_den))%M;
          cout<<f;
      
          return 0;
      }
      

      Above code id not working fow test3 given in question could u plz tell why??

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

        is giving output as 97787202 instead of 94391813.

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

i don't know c is very easy like after 40 to 50 minutes 8-9k solved that problem

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

    i mean, classic known topic

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

      i miss the shit that classy number should have two digit prime number i read like just prime number that why i just finding for some formula , number of prime number less than n n/ln(n) or digit dp , and implementation of that in 20 minutes was stranger for me

»
10 months ago, hide # |
 
Vote: I like it +15 Vote: I do not like it

Why did everyone solve C in the worst possible :sob: This passes:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll good(ll r) {
	ll res = 48 * (r/210);
	for (int i = 0; i < r%210; i++)
		if (!(i%2==0 || i%3==0 || i%5==0 || i%7==0))
			res++;
	return res;
}
int main() {
	int T;
	cin >> T;
	while (T--) {
		ll l, r;
		cin >> l >> r;
		cout << good(r+1) - good(l) << "\n";
	}
	return 0;
}
»
10 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

had so much fun this time, thanks for hosting :)

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

How This is Possible?

Problem B

Testcase : a = 3, b = 7, k = 2

How the Output is here two, No paths allows us to have answer 2 the actual is 3 why Getting 2.

»
10 months ago, hide # |
 
Vote: I like it +44 Vote: I do not like it

4000 people passed D? SMH. Come on guys,stop using AI to cheat in a public CP competition. You benefit NOTHING from doing so. Use your god damn brain instead.

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

I don't understand why the solution I wrote for D does not get correct results, I use DP on m + 1 states setting dp[0] = 1 and all other states are set to 0, and then sort the segments based on l first then r then I do transition like that : let current segment be from l to r with p probability then dp[r] += (dp[l-1] * p) mod m, another thing I do I just transform every p and q to p by p* (q^m-2) mod m, what is wrong with that?

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

My rating is 403 if i was able to solve 1 question only div 2 educational contest will my rating will increase or decrease penalty 43

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

I have just solved C using chatgpt here is submission the problem is good and educational but it's obvious and easy for anyone know the theory (including AIs)

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

I tried using deepseek for todays contest problem D (obv after contest)

It solved in just one prompt the full correct solution

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

did anyone solve D with a recursive DFS-type approach(not DP)?

I think it was possible to start with the segments with l=1, then check all the segments starting at the endpoints of these segments, and continue this proccess. We can store the probability for every segment and store which segments have been visited(like a dfs).

I wasn't able to complete the implementation so not completley sure if it works.

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

Can anyone please send the solution of the third problem. And different approaches to solve the B problem

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

Can someone please explain the solution of tourist for problem D?

I didn't understand why he used the odds ratio

auto q = x / y;
p[i] = q / (1 - q);
  • »
    »
    10 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    You need to calculate sth like:

    $$$ p_i \cdot \prod_{j \ne i, j \in S} (1 - p_j) = p_i \frac{1 - p_i}{1 - p_i} \prod_{j \ne i, j \in S} (1 - p_j) = \frac{p_i}{1 - p_i} \prod_{j \in S} (1 - p_j) $$$

    And the last product is a prefix product which can be precalculated

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

      Got it, thanks

      But I still can't understand the DP transition to maintain the probability

      I think we maintain the value for each $$$i \in m$$$ like this

      Suppose we have the set $$$K$$$ that contains all the segments ending in index $$$i$$$

      $$$ P(i) = \sum_{j \in K} P[j.\text{start}] \cap P(\text{i exists}) \cap P(\text{all other segments don't exist except the ones in P(j.start)})] $$$

      I see the value of $$$P(\text{i exists}) \cap P(\text{all other values don't exist})$$$ is maintained correctly by the expression you gave above but maintaining the existence probability of segments in $$$P[j.start]$$$ is not obvious

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

      Thanks for the explanation, but I still didn't quite get it.

      $$$\text{coeff} = p_i \cdot \prod_{j \neq i, j\in S}(1 - p_j)$$$ is the probability that the $$$i$$$-th segment appears and all other segments don't appear.

      $$$dp[k]$$$ is the probability of covering the first $$$k$$$ cells.

      Then the product $$$dp[k] \cdot \text{coeff}$$$ doesn't make sense to me. On the one hand, $$$\text{coeff}$$$ doesn't allow any segments other than $$$i$$$-th segment to appear. On the other hand, $$$dp[k]$$$ allows some segments other than $$$i$$$-th segment to appear.

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

      Oh I got it.

      $$$dp[0] = \prod_{j\in S} (1- p_j)$$$ is the probability that no segment appears.

      Suppose the first $$$k$$$ cells can only be covered by the $$$s$$$-th segment, then the probability is $$$dp[k] = {p_{s} \over 1 - p_{s}} \cdot \prod_{j\in S} (1- p_j)$$$

      Suppose the next $$$l$$$ cells can be covered by the $$$t$$$-th segment, then the probability is $$${p_{t} \over 1 - p_{t}} \cdot {p_{s} \over 1 - p_{s}} \cdot \prod_{j\in S} (1- p_j) = dp[k] \cdot {p_{t} \over 1 - p_{t}}$$$.

      $$$dp[k]$$$ already makes sure that the $$$s$$$-th segment would appear.

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

        Your explanation helped me to understand it too

        Thank you too much

        BTW it works with paths summation also, multiplying $$$\frac{p_t}{p_t-1}$$$ by $$$dp[k]$$$, means to distribute the fraction to be multiplied by each selected path then take $$$\cup$$$ to them all

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

I can't believe there are over 4000 solves on D. I thought I was doing pretty good when I solved it around the 70 minute mark. I guess it was not such a difficult problem after all...

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

can anyone explain the sol of D?

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

    First of all, notice that each points must be covered by exactly one segment.

    Let the success probability be the probability that the segment exists, and the failure be the probability that the segment fails to exist.

    Assume that you have a set named $$$S$$$, where $$$S$$$ contains any set of segments indices that can cover all the points.

    $$$\newline$$$
    $$$P(\text{A valid tiling}) = \prod_{i \in S} P_{i}(success) * \prod_{i \notin S} P_{i}(failure)$$$

    This is how to calculate the probability of one valid tiling, but we need all the different combinations of valid tilings.

    We have

    $$$ P_{i}(\text{success}) = \frac{p_{i}}{q_{i}} \text{ and } P_{i}(\text{failure}) = \frac{q_{i} - p_{i}}{q_{i}}, $$$

    and since

    $$$ P(\text{A valid tiling}) = \prod_{i \in S} P_{i}(\text{success}) \cdot \prod_{i \notin S} P_{i}(\text{failure}) $$$

    is just products, we can do the following trick.

    $$$\newline$$$
    $$$P(\text{A valid tiling}) = \prod_{i \in S} P_{i}(success) * \prod_{i \notin S} P_{i}(failure)$$$
    $$$= \prod_{i \in S} (\frac{p_{i}}{q_{i}}) * \prod_{i \notin S} (\frac{q_{i} - p_{i}}{q_{i}})$$$
    $$$= \prod_{i \in S} (\frac{p_{i}}{q_{i} - p_{i}} * \frac{q_{i} - p_{i}}{q_{i}}) * \prod_{i \notin S} (\frac{q_{i} - p_{i}}{q_{i}})$$$
    $$$= \prod_{i \in S} (\frac{p_{i}}{q_{i} - p_{i}}) * \prod_{\{i \notin S\} \cup \{i \in S\}} (\frac{q_{i} - p_{i}}{q_{i}})$$$
    $$$\newline$$$

    Notice that the right term is the global product failure, so factor out this, calculate it and save it in a variable for a later multiplication.

    The first term can be calculated using DP for different tiling combinations, and then multiply by the factor

    $$$\frac{p_{i}}{q_{i} — p_{i}}$$$
»
10 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

What do you guys think is the probable rating of C?

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

    1000-1200, standard PIE problem, once you understand PIE it’s super easy. But this is just my personal guess. As many people are saying, its rating will be deflated due to cheaters.

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

      Im surprised I didn't know about PIE before this contest, it is very well known topic apparently.

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

        Yeah it’s fine, I know about it only because I did competitive math in high school. Take more contests and that stuff will stop happening. Learning is the whole point of edu.

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

I can't believe so many people solved Problem D. I suspect that many of them used AI to solve it.

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

    Same with C honestly, inclusion-exclusion principle is a pretty standard trick but not one that I would expect the average 1200-rated user to know

»
10 months ago, hide # |
 
Vote: I like it +16 Vote: I do not like it

It took me 1 hour and 30 minutes to do problem D. It took me like 20 minutes, basically way longer than it should've taken me, to figure out how to manually calculate the simple first test case, and then it didn't take me that long to figure out the DP formula after that and it was correct from about the first time I figured it out, but then it took me at least 40-50 minutes to debug mistakes which were ALL related to mixing up (1 - p) and 1/p (e.g. using (1 — p) instead of 1/x to get range product from a prefix product, using 1/p instead of (1 — p) for probability not, basically really stupid mistakes), before managing to submit and AC in the last 5 minutes lol.

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

bruhh i forgot it cauze hollow knight

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

Yay, my first ever hacks! They are super simple inputs though, they (or similar) should have been part of the pre-tests imo.

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

AIForces Edu Round. A~C are brainless. My grandma can solve them with her toes.

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

    My grandma runs faster than the code

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

    To be fair, if not for the existence of our AI overlords, problem C was a nice educational problem since it relied on the inclusion-exclusion principle which is a common mechanism in some more difficult problems (although here, obviously, it was just hardcodable)

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

Why is it unrated?My performance was good(4 problems solved),and I hoped a lot on it,but it is unrated!

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

Why was Div2 cinsidered unrated for me? I selected rated?

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

Can anyone explain as to how the first test case has the answer 5/18 for the Problem D

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

    I made the same mistake Basically the entire segment will be on/off with probability not individual cells

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

    There are two cases that all cells are covered exactly once: The 1st and the 2nd segment appear, the 3rd one doesn't appear; or the 3rd one appears and others don't.

    Than the answer is $$$\frac{1}{3}\times \frac{1}{2}\times\left(1-\frac{2}{3}\right)+\left(1-\frac{1}{3}\right)\times \left(1-\frac{1}{2}\right)\times \frac{2}{3}=\frac{5}{18}$$$.

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

Can problem D be solved with sweep line and partial product?

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

speedforces, AIforces, ...

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

How to solve E ?????

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

    It looks like a Knapsack problem.

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

      I could derive one observation. Sum couldn't be more than 2*x ( x is given in the input ).

      But couldn't proceed further than that.

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

        If the original array a contains the element 1, we can add 1 to a, causing all elements in the complementary sum set Q to increase by 1.
        Examples:
        - a = {1, 2, 3, 4}Q = {6, 7, 8, 9}
        - a = {1, 1, 2, 3, 4}Q = {7, 8, 9, 10}

        Now consider incrementing suffixes in a:
        - For i=2: Modify a to {1, 2+1, 3+1, 4+1}Q = {6+2, 7+2, 8+2, 9 + (n - i + 1 = 3)}
        - For i=3: Modify a to {1, 2, 3+1, 4+1}Q = {6+1, 7+1, 8+2, 9 + (n - i + 1 = 2)}

        Define an array dp[y], where y represents the maximum value in Q.
        When incrementing suffixes starting at position i in a, the dynamic programming update rule becomes:
        dp[y] += dp[y - (n - i + 1)]

        Finally, to calculate how many 1s can be inserted into a (given a target maximum x):
        ans += dp[y] * (x - y + 1)

        #include <iostream>
        #include <algorithm>
        #include <cstring>
        #include <vector>
        #include <climits>
        #include <unordered_map>
        #include <queue>
        #include <deque>
        #include <math.h>
        #include <limits.h>
        #include <set>
        #include <stack>
        #include <map>
        #define ll long long
        #define double long double
        using namespace std;
         
        const ll N=1e6+10,M=5e5+10,MOD=998244353;
         
        const double EPS=1e-12;
         
        typedef pair<ll,ll> pii;
        typedef pair<ll,pair<ll,ll> > piii;
        typedef pair<ll,piii> piiii;
         
        ll n,m;
        
        
        void reset()
        {
            
        }
         
        void solve()
        {
            cin>>n>>m;
            if(n==1){ cout<<m; return; }
            vector<ll> dp(m+1,0);
        
            ll t=(n+1)*n/2-1;
            if(t>m) {cout<<0; return ;}
        
            t=m-t;
            dp[0]=1;
            for(ll i=2;i<=n;i++)
            {
                for(ll j=n-i+1;j<=t;j++)
                {
                    dp[j]+=dp[j-(n-i+1)];
                    dp[j]%=MOD;
                }
            }
        
            ll ans=0;
            for(ll i=0;i<=t;i++) ans+=(dp[i]*(t+1-i))%MOD,ans%=MOD;
            cout<<ans;
        }
         
        int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(0);
        
        
         
            ll t; cin>>t;
            while(t--)
            {
                solve();
                reset();
                cout<<'\n';
            }
             
             
            return 0;
        }
        
        

        My English and expressive abilities are limited, so my explanations might be a bit unclear. Sorry.

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

.

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

So much math honestly, a bit tough as it was my first time on codeforces. I'm your usual leetcode guy.

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

Hello Codeforces team,

I received a plagiarism warning for my solution to Problem C (2122C): https://mirror.codeforces.com/contest/2122/submission/329867080.

I would like to clarify that I solved the problem entirely by myself and did not copy anyone else’s code. The approach I used (sorting by x, splitting into two halves, and sorting again by y) is a common one, and this may have caused similarities with other users’ solutions.

I did not share my code or collaborate with anyone during the contest. If needed, I can provide my thought process, logic, or handwritten notes.

Kindly review the case. Thank you for your time.

Regards,
karyampudikomal417

»
10 months ago, hide # |
 
Vote: I like it +13 Vote: I do not like it

The difference between D and E is too much ,problems are ok but this problemset shouldn't be approved.

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

    Yeah, also D was relatively easy so it was a bit speedforces for the mid-rated users... But I think C and D are pretty cool problems at least

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

Loved the contest! Also, my first A, B, C in Div. 2.

Yay

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

Clean solution for problem C:


void solve() { ll l, r; cin >> l >> r; // basically we need to remove all multiples of single digit primes and avoid double counting const auto ans = [](ll n) { ll ans = n; int primes[] = {2, 3, 5, 7}; for (auto prime : primes) { ans -= n / prime; } for (int i = 0; i < 4; ++i) { for (int j = i + 1; j < 4; ++j) { ans += n / (primes[i] * primes[j]); } } for (int i = 0; i < 4; ++i) { for (int j = i + 1; j < 4; ++j) { for (int k = j + 1; k < 4; ++k) { ans -= n / (primes[i] * primes[j] * primes[k]); } } } ans += n / (2 * 3 * 5 * 7); return ans; }; cout << ans(r) - ans(l - 1); }
»
10 months ago, hide # |
 
Vote: I like it -9 Vote: I do not like it

Dear Codeforces team,

I received a plagiarism warning regarding my submission 329503821 for problem 2126B. I want to clarify that I did not copy or intentionally share my solution. If there was any unintentional leakage (e.g., through an online IDE with public access), I sincerely apologize. I respect Codeforces' rules and will be careful going forward.

Please review my case. Thank you for your time and consideration.

— siripuramvinodkumar333

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

    Using iostream, excessively verbose comments, unusually long variable names, and mixing C++ with Python in a single contest submission- these patterns strongly indicate that the solution was generated using AI tools. It would be more appropriate to acknowledge this openly and consider refraining from participating in competitive programming under such circumstances.

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

为什么我这一场比赛的rating到现在还没有结算嘞?为什么主页的比赛记录显示unrated?

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

is it unrated

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

Editorial when? Want to figure out how F right now.

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

can any correct why this is wrong for problem -B

if (a == b || (gcd(a, b) <= k && gcd(a,b)!=1) || (a <= k && b <= k) || (a == 0 && b != 0) || (b == 0 && a != 0)) cout << 1 << endl; else cout << 2 << endl;

  • »
    »
    10 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it
    long long a,b,k;
        cin>>a>>b>>k;
        long long m=gcd(a,b);
        if(a/m<=k&&b/m<=k) cout<<1<<endl;
        else cout<<2<<endl;

    u have included multiple checks which can be done in a single line. Also, if you have failed in testcase 3 it might be due to int overflow that can be catered by long long type variable, committed this mistake in contest.

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

    This case is wrong: (gcd(a, b) <= k && gcd(a,b)!=1)

    gcd(a, b) only indicates how many times you have to use the operation, not the actual lengths of dx and dy. Consider this test case:

    1

    2 6 2

    Your code will give 1, because gcd(2, 6) = 2 <= k

    But in reality, it needs to use dx = 1 and dy = 3 for the cost to be 1, but dy = 3 > k so the answer should be 2.

    To calculate dx, dy:

    dx = a / gcd(a, b)

    dy = b / gcd(a, b)

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

when will ratings came?

»
10 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it
 ``` #include <bits/stdc++.h> using namespace std; long long gcd(int y, int x) { while (x) { y %= x; swap(y, x); } return y; } int LeftDown(long long a, long long b, long k) { if (a <= k && b <= k) { return 1; } long long x = min(a, b), y = max(a, b); if (x > 0 && y > 0) { long long d = gcd(y, x); a /= d; b /= d; if (a <= k && b <= k) { return 1; } } return 2; } int main() { int t; cin >> t; while (t--) { long long a, b, k; cin >> a >> b >> k; cout << LeftDown(a, b, k) << endl; } return 0;   Whats wrong in this code its giving wrong answer on 3rd test } ``` 
»
10 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Why this contest is classified as unrated I wanted to increase my ELO?!__

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

got +413! I'm finally rated on codeforces!

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

Any tips to beginners for reaching master quickly in minimum amount of contest

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

Hope it helps me to become pupil :)

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

Hello, my solution was flagged as coinciding with others. I realize I might have unknowingly caused this (maybe by using a public IDE). I assure you that I will never repeat this mistake again and will strictly follow Codeforces rules. Please give me another chance.

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

Hello, I recently received a plagiarism warning for my submission. I understand that my solution was flagged as similar to others. I realize that I might have unknowingly caused this issue, possibly by using a public IDE or by not being careful about keeping my code private. I take full responsibility and assure you that I will strictly follow Codeforces rules in the future. I will only use my own account, avoid sharing solutions, and never make my code public during contests. Please consider giving me another chance. I will make sure this does not happen again.

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

Hi,

My submission to the problem 2125D has been skipped due to similarity with some other submissions.

Binary exponentiation for modular inverses under a prime modulus is standard in competitive programming. Fermat’s Little Theorem (a^(mod−2)) for inverses under a prime modulus is also standard in CP.

The expression used ((q-p+MOD)%MOD)* invq%MOD is inevitable when implementing (q-p)/q in modular arithmetic.

Below is my template which I used for this question: Link

Question 2125C was also from my notes,99% same code,see yourself Link

Please look into this matter awoo,MikeMirzayanov and unskip my submission.

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

Educational Codeforces Round 181 (Rated for Div. 2) Dear Codeforces Team,

I am writing to respectfully appeal the plagiarism notice regarding my solution 330384162 for problem 2125D. The system has flagged it as being significantly similar to submissions from Niki_fx/330343057 and others. However, upon manual inspection, I believe this is a false positive.

Here is a comparison of the key differences:

  • My code uses custom type aliasing with using ll = long long and modexp for modular inverse.
  • I used a completely different variable naming convention (totalB, ends, dp, etc.) and modular arithmetic structure.
  • The dynamic programming approach and weight calculations are independently implemented.
  • Structurally, my code flow and formatting are different; I do not use macros like int64, int128, all(), or debugging conditionals (#ifdef DEBUG) as used in the flagged submission.
  • I did not share my solution or use any external code. I also did not use public code-sharing platforms like ideone.com or pastebin with public visibility.
  • I do not know this person also and I do not know how the similarity happened.

Attached below is my full solution (also visible in the submission):

If any similarity has arisen, it is purely coincidental or likely due to the constraints of solving a structured DP problem involving modular arithmetic with probabilistic weights — which tends to have common patterns (e.g., use of modular inverse, array of vectors, and accumulation loops).

Please look into this matter awoo,MikeMirzayanov, and I kindly request you to lift the plagiarism flag and restore any rating penalties if applicable.

Thank you for your time and for maintaining the integrity of the platform.

Sincerely,
Codeforces handle: lonely_warrior_lak0708

My Code (lonely_warrior_lak0708, Submission 330384162)


~~~~~ #include <bits/stdc++.h> using namespace std; using ll = long long; const ll MOD = 998244353; ll modexp(ll a, ll e = MOD - 2) { ll r = 1; a %= MOD; while (e) { if (e & 1) r = (r * a) % MOD; a = (a * a) % MOD; e >>= 1; } return r; } void solve() { int n, m; cin >> n >> m; vector<vector<pair<int, ll>>> ends(m + 1); ll totalB = 1; for (int i = 0; i < n; i++) { int l, r; ll p, q; cin >> l >> r >> p >> q; ll A = p % MOD * modexp(q) % MOD; ll B = (1 + MOD - A) % MOD; totalB = totalB * B % MOD; ll w = A * modexp(B) % MOD; ends[r].emplace_back(l, w); } vector<ll> dp(m + 1, 0); dp[0] = 1; for (int x = 1; x <= m; x++) { ll sum = 0; for (auto &seg : ends[x]) { int l = seg.first; ll w = seg.second; sum = (sum + dp[l - 1] * w) % MOD; } dp[x] = sum; } ll ans = totalB * dp[m] % MOD; cout << ans << "\n"; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t = 1; // cin >> t; while (t--) solve(); return 0; }



Flagged Code (Niki_fx, Submission 330343057):
#include <bits/stdc++.h>
using namespace std;
#define int64 int64_t
#define int128 __int128
#define all(a) std::begin(a), std::end(a)

static const int mod = 998244353;

int64 modpow(int64 a, int64 n = mod - 2) {
    int64 res = 1;
    while (n) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int n, m;
    cin >> n >> m;

    vector<vector<pair<int,int>>> a(m + 1);
    int64 prod = 1;
    for(int i = 0; i < n; i++){
        int l, r;
        int64 p, q;
        cin >> l >> r >> p >> q;
        int64 temp = p % mod * modpow(q % mod) % mod;
        int64 b = (1 - temp + mod) % mod;
        int64 c = temp * modpow(b) % mod;
        prod = prod * b % mod;
        a[r].emplace_back(l, int(c));
    }
    vector<int64> dp(m+1, 0);
    dp[0] = 1;

    for(int x = 1; x <= m; x++){
        int64 sum = 0;
        for(auto &pr : a[x]){
            int l = pr.first;
            int64 c = pr.second;
            sum = (sum + dp[l-1] * c) % mod;
        }
        dp[x] = sum;
    }

    int64 ans = prod * dp[m] % mod;
    cout << ans << "\n";

    return 0;
}

~~~~~

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

I recently received a message that my solution for Problem 2125B (Submission ID: 330358733) significantly coincides with other users’ submissions.

I want to clarify that I wrote the solution independently during the contest and did not engage in any kind of collaboration or cheating. However, after reviewing the situation, I realized that I may have accidentally made my submission publicly visible on a GitHub repository that I was using to track my contest practice and submissions.

If that is indeed the cause of the similarity, I sincerely apologize — it was entirely unintentional and due to a lack of awareness about the implications of keeping such repositories public. I have since made the repository private and will take all necessary precautions to ensure this does not happen again.

I respect the rules of Codeforces and the integrity of competitive programming and hope you will take this context into consideration.

Please let me know if any further clarification is needed.

Sincerely,

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

I received a message about code similarity in my submission for problem 2125A.

→ Submission ID: 330336557
→ Username: Darsh_01

I have an explanation for this because on_loop is my other account for my brother and when I gave the contest, it was logged in that account but while solving the problem 1 I did not realize it till i submitted, so I then changed to my original account, submitted that code and then solved further problems from my original account. I am soory for this and will make sure this will not happen any further. Let me know if further clarification is needed. You may check the login email-id for both accounts, they are same as these both are my accounts only

Regards,
Darsh_01

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

As I attempted this contest round ,I suggest everyone to try this as a virtual Contest