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

Автор awoo, история, 14 месяцев назад, По-русски

Neapolis University Pafos

Привет, Codeforces!

Благодаря поддержке Neapolis University Pafos, продолжается серия образовательных раундов. Университет предлагает получение степени бакалавра в области компьютерных наук и искусственного интеллекта со стипендиями JetBrains. Получите передовые навыки в области искусственного интеллекта и машинного обучения, которые подготовят вас к востребованным техническим карьерам. Доступно ограниченное количество стипендий. Не упустите свой шанс учиться в Европе бесплатно!

В 22.07.2025 17:35 (Московское время) состоится Educational Codeforces Round 181 (Rated for Div. 2).

Этот раунд будет рейтинговым для участников с рейтингом менее 2100. Соревнование будет проводиться по немного расширенным правилам ICPC. Штраф за каждую неверную посылку до посылки, являющейся полным решением, равен 10 минутам. После окончания раунда будет период времени длительностью в 12 часов, в течение которого вы можете попробовать взломать абсолютно любое решение (в том числе свое). Причем исходный код будет предоставлен не только для чтения, но и для копирования.

Вам будет предложено 6 или 7 задач на 2 часа. Мы надеемся, что вам они покажутся интересными.

Задачи вместе со мной придумывали и готовили Адилбек adedalic Далабаев, Иван BledDest Андросов, Максим Neon Мещеряков, Максим FelixArg Новоточинов и Полина ifive Пикляева. Также большое спасибо Михаилу MikeMirzayanov Мирзаянову за системы Polygon и Codeforces.

Спасибо тестерам раунда shnirelman и Brovko за ценные советы и предложения!

Удачи в раунде! Успешных решений!

UPD: Разбор опубликован

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

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

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

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

The CSAI curriculum link leads to a deleted file.

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

As a tester, i recommend!

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

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

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

I hope it goes well

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

pls postpone this contest by 2 hours I have doctor appointment

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

less go. another edu round :fire

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

another edu, hoping to get back to pupil

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

Is this competition has open hack?

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

I hope to educate in this round

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

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

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

what about score distribution ?

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

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

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

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

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

    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.

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

aahhh. bad experience for me, cause swap n, m I took about 30-40 min on debuging.

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

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

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

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

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

AiForces

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

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

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

No way these many people were able to solve problem D, I suspect AI.

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

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

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

    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))

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

MathForces :)

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

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

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

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

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

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

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

C got me bad

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

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

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

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?

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

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

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

      Can you explain why GCD ? please.

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

        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.

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

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.

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

    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.

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

    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)

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

How to E?

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

E is definitely NTT

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

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

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

      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))$$$

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

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

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

      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.

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

from D to E is always hard to me

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

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

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

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

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

was D dp on tree? i tried to dfs for each u to v and dp[u] stores a pair which is the probability that i can reach m from node u

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

how to C?

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

    simply consider 16 cases...

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

    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.

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

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?

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

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

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

Can F be solved with lambda?

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

    Yes it can be!

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

      Would you mind elaborating on this?

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

        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)$$$.

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

          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.

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

            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$$$

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

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

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

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

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

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!

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

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?

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

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$$$

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

    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.

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

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

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

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;
}
»
14 месяцев назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

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

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

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.

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

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.

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

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?

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

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)

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

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

It solved in just one prompt the full correct solution

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

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.

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

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);
  • »
    »
    14 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    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

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

      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

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

      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.

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

      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.

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

        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

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

Nice contest, AIForces.

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

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

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

can anyone explain the sol of D?

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

    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}}$$$
»
14 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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

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

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

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

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.

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

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

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

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

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

Hello everyone

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

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

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

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

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

    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}$$$.

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

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

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

speedforces, AIforces, ...

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

How to solve E ?????

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

    It looks like a Knapsack problem.

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

      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.

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

        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.

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

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

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

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

Yay

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

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

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

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

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

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,

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

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