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

Автор ch_egor, 5 лет назад, По-русски

Спасибо за участие!

1445A - Переупорядочивание массива придумал meshanya, а подготовил ch_egor

1445B - Отборочный этап придумала Андреева Елена Владимировна, а подготовил ismagilov.code

1444A - Деление придумал vintage_Vlad_Makeev, а подготовил grphil

1444B - Разбивай и суммируй придумал и подготовил Kaurker

1444C - Тимбилдинг придумал V--o_o--V, а подготовил wrg0ababd

1444D - Прямоугольная ломаная придумал Zlobober, а подготовил DebNatkh

1444E - Найти вершину придумал V--o_o--V, а подготовил 300iq

Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
  • Проголосовать: нравится
  • +121
  • Проголосовать: не нравится

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

Автокомментарий: текст был обновлен пользователем ch_egor (предыдущая версия, новая версия, сравнить).

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

Fast tutorial!

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

very fast tutorial thanks.

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

Great sets of problems with short statements!

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

Thanks for the quick tutorial!

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

How the heck was this really 14 hours ago? xD

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

I do not understand the sentence: "Any difference |pi−qi| in our sum will be the difference of one element of R and one element of L." Sombody explain the meaning of it?

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

Why does this give WA for (C) Division : https://mirror.codeforces.com/contest/1445/submission/97331021 ?

Fails at 7th Test (Passed the Pretests)

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

Как мы можем найти С из N по 2 * N в задаче D для Div2, если нам нужно выполнять операции по модулю, а в формуле деление? Треугольник Паскаля?

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

    Можно делить в модулярной арифметике по простому модулю. Погуглите modInverse, делается расширенным алгоритмом Евклида, например.

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

What does $$$O(n^2 \log n \ldots n^4)$$$ mean, wtf xd?

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

For Div1 Problem B, I just made random tc for n = 1, 2, 3 and solved on paper. Then I found that cost is always same and got AC xD

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

I misread non-increasing as non-decreasing in problem B and worked almost 2 hours on it(

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

Problem statements were really very straight forward...No time wasted in reading useless story and understanding problem statements

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

Can anyone help with counting $$$С_{2n}^{n}$$$ without overflow?

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

Div2 A, why do we have to check for all i? Like after sorting one array in descending order, shouldn't it be sufficient to check a[0]+b[0] and a[n-1]+b[n-1]? Can someone please give an example where this fail?

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

Did someone managed to solve div1B without the observation that any partition holds equal sum?

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

Can anyone please tell me why is my code giving wrong answer on test 18 for problem C- Division.

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

Thanks for update the rating fast!

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

My rating goes bruh 'cause I forgot to reset res = 0 after each testcase when solving C lol

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

Can someone please explain solution of Problem Div2C/Div1A more clearly?

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится
What's wrong ???
»
5 лет назад, скрыть # |
 
Проголосовать: нравится -7 Проголосовать: не нравится

Please give a detailed explanation of Div 2 C

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

    I understood one approach. Here it is:
    if $$$p\% q\neq 0$$$ then $$$x=p$$$
    else we can represent $$$p$$$ and $$$q$$$ as follows:
    $$$p={p_1}^{k_1}*{p_2}^{k_2} \dots {p_y}^{k_y}*{p_{y+1}}^{k_{y+1}} \dots {p_m}^{k_m}$$$
    $$$q={p_1}^{l_1}*{p_2}^{l_2} \dots {p_y}^{l_y}$$$ where $$$p_1,p_2 \dots p_m$$$ are prime numbers.
    Here $$$k_1 \geq l_1, k_2 \geq l_2, \dots ,k_y \geq l_y$$$ because $$$p\% q=0$$$
    Now we have to take some factor of $$$p$$$ such that it is not divisible $$$q$$$. We can do this by taking some prime number power equal to one less than corresponding power in prime factorization of $$$q$$$ or you can say that we have to divide $$$p$$$ by that prime factor until $$$p$$$ is not divisible by $$$q$$$ . We can do this for all prime factors of $$$q$$$ and take the maximum one. Here is my submission

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

    I don't know if it will make more sense or not the way I thought is ,

    Let's call the power of a prime number in prime factorization of a number prime count.

    if a number(x) has at least one prime count greater than another number(y) than y%x!=0 Suppose , x=2*2*2*2*3

    and y=2*2*3*3*3*5

    then y/x will be something like (3*3*5)/2 which won't be a integer.

    so now for the given two numbers p & q , we need to find a 'x' that where p%x==0 & x%q!=0and we have to make it the biggest. So we start by making x=p (in another way saying taking all the primes in p) then checking for every prime in q can we make the prime count of q greater than that of x. We print which ever gives the largest number.

    vector<ll>primes;//all the primes in the prime factorization of q.
    for(ll i=0;i<primes.size();i++)
    {
        ll x=p;
    
        while(x%primes[i]==0)
        {
           x/=primes[i];
           if(x%q!=0)
           break;
        }
        
        ans=max(ans,x);
    
    }
    

    so suppose ,

    p=2*2*2*2*3

    q=2*2*2*3

    then x will be =2*2*3

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

I passed Div1 D with $$$O(n^2C/bitset)$$$ using "malaysian knapsack", $$$C$$$ is the sum of length.

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

Div2 D/Div1 B is a beautiful problem, with a wonderful proof, thanks

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

1444B — Divide and SumF how to think like that ? can some one explain the way of thinking step by step ? Please

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

    Think of it this way-> Lets say the array is sorted, then the problem get reduced to choosing a subsequence of n elements, reverse it and then find the "cost". Now try to find which elements will always contribute a negative value ( that is -a[i]) and which will contribute a positive value (that is + a[i])............you will realise that elements from 1....n always contribute a negative value, while elements n+1.....2n contribute a positive value. In the end just multiply the final answer with the number of possible combinations.

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

In the editorial of Problem C, why q is not divisible by x?

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

proplem b was not clear enough and the proplem must be more than that

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

How can one solve Div2D if p and q are both sorted in non-decreasing order? (spent hours trying to upsolve this variant then saw the editorial and was like f**k me :P )

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

Problem E appeared at the eleventh POI.

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

Can someone explain , why the solution got WA ? Thanks in Advance!! Problem — Div2A Link to my solution :https://mirror.codeforces.com/contest/1445/submission/97363313

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

There should be a special tag for problems like 2D/1B: LOL problem

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

The way I thought about problem DIV2-D : Every element either gets added or subtracted, if we consider individual contribution of elements.
Added : when the corresponding element in other sequence is lesser;
Subtracted: when the corresponding element in other sequence is greater;

Let's now see when an element is subtracted : Consider p, q be the non-decreasing and non-increasing sequences respectively;

=> p[1] <= p[2] <= ....... <= p[n] ------- (1)
=> q[1] >= q[2] >= ....... >= q[n] ------- (2)

Let's say p[i] contributes it's negative, i.e. it gets subtracted, Then we can say from (1) that number of elements greater than or equal to p[i] are n-i; Also since q[i] >= p[i] (as p[i] is being subtracted), all of (q[1], q[2] .... q[i]) >= p[i];
Now we can say that atleast (n-i) + i = n elements are greater or equal to p[i];

Similarly we can derive the condition for the other case !

Which proves that for a value to contributes it's negative it has to be in first half of the sorted array of all values !
Hope it helps, sorry if this approach is mentioned above, I dint read all the comments !

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

There is a spell mistake in solution of 1C.

Para.4, the last word "answer" was mistaken for "asnwer".

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

Fun Fact — sinus_070 was the first person to get an AC on 1B/2D. That's because he created the same problem on topcoder a few months ago. Click 1 Click 2

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

In Div1C, there are lots of submissions AC using DSU to find the number of "bad pairs" instead. Could anyone explain a little bit about this solution? Thanks so much <3.

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

Verdict shows accepted then why my rating decreases?

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

Can somebody please explain me the logic of div 2 C. Please..

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

Am I the only person who felt Div2-D is easier than Div2-C ?

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

    Div2-D is easy once you see that property that the sum is same for all permutations. If not, then not. Additionally the statement was formulated in a way that it was easy to get it wrong concerning the ordering of the two halfs L and R.

    Div2-C on the other hand is fairly clear, all that division and things. What else can we do than a prime factorization of the only value where we can do it? Once realized that it is not so hard to use the fatorization to construct ans.

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

Can anybody please explain me the editorial of problem A. Div2 ? I am not getting it please!

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

    Consider the smallest value in a[], min(a[]). Which one of b[] values would be "the best" to pair with that?

    Well, in b[] there is a biggest value, max(b[]). If $$$max(b[])+min(a[]) \gt x$$$, then there is obviously no solution.

    Else it is optimal to "get rid of max(b[])" by using it. Then repeat with the next smallest value in a[]... same again, you will pair it with the then biggest value in b[].

    You end sort a[] ascending, and b[] descending, and checking all pairs a[i]+b[i].

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

About 1444C - Team-Building, can anybody please explain me the sentence "If the path of the cycle in this component ends in the same side where it has started, then it has even length, and odd otherwise."? Thanks in advance.

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

How to solve 1444B - Divide and Sum if $$$f(p,q)$$$ set to be $$$f(p,q) = \sum_{i = 1}^n x_i y_i$$$

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

    Now, I know how to do it in $$$O(n^2 \log n)$$$ time complex and $$$O(n^2)$$$ space complex if $$$f(p, q)$$$ is bilinear.

    Just note that if $$$x_i$$$ belong to the left side, then $$$y_i$$$ belong to the right side, and vice verse.

    So we only have to consider $$$f_k(p, q) = \sum_{i = 1}^k x_i y_i$$$ with $$$x_k$$$ in the left side and $$$y_k$$$ in the right side.

    And the answer with be $$$\displaystyle 2 \sum_{p, q} \sum_{k = 1}^ n f_k(p,q)$$$

    In order to compute $$$\displaystyle \sum_{p, q} f_k(p, q)$$$, we only have to computer sum of $$$k$$$-subarry of left and right side. donated by $$$(l_1, \cdots, l_k)$$$ and $$$(r_1, \cdots, r_k)$$$, and then $$$\displaystyle \sum_{p, q} f_k(p, q) = \sum_{i = 1}^k l_i \cdot r_i$$$.

    the origin time complex is $$$O(n^3)$$$, but there is a convolution in above computation, so we can solve this problem with time complex $$$O(n^2 \log n)$$$ with the help of NFT.

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

Please help, I want to know where and why O(r) code for nCr mod p fails!!!

long long nCr(int n, int r){
    if(r>n){
        return 0;
    }
    int i= 0;
    int t =r;
    long long ans = 1;
    while(t--){
        ans = ( (ans*(n-i))/(i+1) ); // ans is always less than p, so it won't overflow, right??
        ans = ans%p;  
        i++;
    }
    return ans%p; 
}
»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

how solve problem D if it is given that both sequence should be non-decreasing order or non-increasing order?

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

how to solve problem D if it was given that both p & q should be non-increasing order or non-decreasing order?

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

.

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

Can someone please explain why my div1-b solution is failing on test case — 8. Div1-B Solution

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

The answer for the test case (P=557307185726829409 && Q= 746530097)according to the judge is X=1 why cant we have X=674968226.