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

Привет, Codeforces!

В 27.10.2020 17:35 (Московское время) состоится Educational Codeforces Round 97 (рейтинговый для Див. 2).

Продолжается серия образовательных раундов в рамках инициативы Harbour.Space University! Подробности о сотрудничестве Harbour.Space University и Codeforces можно прочитать в посте.

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

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

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

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

Поздравляем победителей:

Место Участник Задач решено Штраф
1 Um_nik 7 149
2 jiangly 7 193
3 hank55663 7 214
4 neal 7 231
5 uwi 7 250

Было сделано 205 успешных и 712 неудачных взломов.

И, наконец, поздравляем людей, отправивших первое полное решение по задаче:

Задача Участник Штраф
A Drew_is_me 0:01
B Drew_is_me 0:03
C IgorI 0:03
D xb0nS 0:09
E vinfat 0:17
F SunshinePie 0:28
G tfg 0:13

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

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

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

Is it only me or other people also feel that educational rounds are harder than div2 rounds(considering they have more number of questions)?

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

*Во вторник)))

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

[cf comment sections these days: no offense ](cf)

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

One more Educ from awoo!

Hope, that Educ will be as good as last one from you)

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

can I go to 2000? :)

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

can i go to 2000 rating QAQ

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

Is it rated ?

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

why does people love spamming CF announcements with "is it rated?" it's so annoying & frustrating !

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

comment deleted, figured it out

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

6 minutes left time to be ready : )

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

Upvote if you lose some rating because of this round :(

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

Мое решение задачи G скомпилировалось и дало правильный ответ для претестов на моей машине, но в проверяющей системе оно вывело неправильный ответ(.

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

In one of the examples, the range of cans that the customer could buy was between 3 and 4. How could we sell a pack with 5 cans to him (according to explanations?

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

Wtf is pretest 2 in C

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

How to solve C ? My greedy solution didn't work :( .

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

.

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

How to solve B ?

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

Am I the only one who misread problem D and tried to solve thinking it was DFS for most of the contest T_T

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

how to do B ??

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

Isnt B much harder than D or im missing something obvious?

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

RIP my ratings

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

How to solve B?

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

    Here is an intuitive solution that worked for me.

    For each consecutive pair of 1s, u have to insert a 0 between them and u will always have a "smart way" to do that in a single move(considering the fact that we have equal zeroes and ones). The same holds for pair of zeroes as well.

    Doing it for a single pair of 1s, also do the job for a single pair of 0s. So count the consecutive 0s(00)-> cnt0 and 1s(11) -> cnt1, then max(cnt0, cnt1) will be the answer.

    Hope it helps.

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

    At this kinds of problems, you usually want to search for alternative statements that are more helpful. We can see that we could reframe it as: given a string s consisting of n/2 0's and n/2 1's, lets define f(s) = the number of i for which s[i] = s[i + 1], 1 <= i < n.

    To make s alternating, we want to make f(s)=0.

    A reverse operation changes f(s) with at best 2. So f(s) can be decreased with at most 2 in one operation. A lower bound for the answer to this problem is ceil(f(s)/2).

    Now we only have to prove that you can always decrease f(s) by 2, excepting the case where f(s) = 1.

    if f(s) > 1, then we will always have at least a pair of consecutive 0's and at least a pair of consecutive 1's. So we can just reverse the substring cotaining one of this 1's and one of this 0's and decrease f(s) by 2.

    For example s = 01001011,f(s) = 2. we have the 0 pair (3,4) and the 1 pair (7,8). So if we reverse (4,7) we get 01010101.

    If f(s) = 1, than the string will have to be either 0101..0110101...1010 or 1010....1001...0101. So you can reverse a prefix/suffix and decrease f(s) by 1, arriving at f(s)=0.

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

Guys, where can I hack? I don't see any locks..

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

how to solve G? is nsqrtnlogn supposed to pass? (I had tle on test 17)

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

problem 2 ~~~~~ string solve(){ // CALM DOWN : — )

ll n;
cin>>n;

string s;
cin>>s;

ll l=0;
ll r=n-1;
vector<char> ans1(n);
bool t=0;

for(int i=0;i<n;i++){
    if(t){
       ans1[i]=('0');
       t=!t;
    }else {
       ans1[i]=('1');
       t=!t;
    }
}

ll tl=l;
ll tr=r;
ll last=0;
bool rev=0;

while(l<r){

    while(l<r and s[l]==ans1[tl]){
       l++;
       if(rev==0){
         tl++;
       }else tl--;
    }

    while(l<r and s[r]==ans1[tr]){
       r--;
       if(rev==0)
         tr--;
       else tr++;
    }



    if(l>=r) break;

    last++;
    swap(tl,tr);
    rev=!rev;
}


l=0;
r=n-1;
tl=l;
tr=r;
ll last1=0;
rev=0;

while(l<r){
    while(l<r and s[l]!=ans1[tl]){
       l++;
       if(rev==0){
         tl++;
       }else tl--;
    }
    while(l<r and s[r]!=ans1[tr]){
       r--;
       if(rev==0)
         tr--;
       else tr++;
    }

    if(l>=r or l>=n or r<0) break;

    last1++;
    swap(tl,tr);
    rev=!rev;
}


ret(min(last,last1));

ret(""); } ~~~~~ why this code is giving TLE .... i have created both the ans array and then used 2 pointer one pointer at left and another at right and i swap the pointers please if any one could help

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

WTF is test 11 in E?

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

Very nice problemset.

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

Even D was much easier than B.. what the hell is answer to B ?

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

What is the expected time complexity for E?

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

In problem D , for first vertex 1 i considered largest increasing sub-sequence starting from i=2 as it's children . For example if input was 1,2,3,5,6,4 . I considered 2,3 as child of 1 and 5,6 as child of 2 and 4 as child of 3 . What is wrong in this approach or in my solution

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

I try to hack C but it returns this: FAIL Expected EOLN (test case 1, stdin, line 3, why?

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

Can someone explain how to prove the answer to B is just half the number of positions where $$$s_{i} = s_{i + 1}$$$ cyclically? It intuitively feels correct as we can fix at max 2 such positions in each operation but I have no clue how to prove that we always can.

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

    If there are at least $$$2$$$ positions to fix, there are always indices $$$x, y$$$ such that $$$s_x = s_{x+1} = 0$$$ and $$$s_y = s_{y+1} = 1$$$.

    Proof by contradiction: suppose wlog that $$$s_i = s_{i+1} = 0$$$ is false for each $$$i$$$.
    Let $$$z_i$$$ be the position of the $$$i$$$-th $$$0$$$. Then, the inequality $$$2(j - i) \leq z_j - z_i \leq 2(j - i) + 1$$$ holds.

    But there are two positions to fix, so $$$z_{i+1} - z_i = 3$$$ should hold for two indices $$$i = a, b$$$, $$$a \lt b$$$.

    Then $$$z_{b+1} - z_a = (z_{a+1} - z_a) + (z_b - z_{a+1}) + (z_{b+1} - z_b) \geq 3 + 2(a + b - 1) + 3 = 2a + 2b + 4$$$.

    But $$$z_{b+1} - z_a \leq 2(a + b + 1) + 1 = 2a + 2b + 3$$$ (contradiction).

    So $$$x, y$$$ exist, and you can fix $$$2$$$ positions by reversing either $$$[x + 1, y]$$$ or $$$[y + 1, x]$$$.

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

    My solution was also intuitive , although I didn't consider it as a cycle. I counted positions where $$$s_{i}=s_{i+1}$$$ and $$$ans = (cnt+1)/2$$$. No idea why this works either but it just seemed right and it passed. Was able to solve B in just 4 mins. Felt really good after failing terribly in the Techno Cup :)

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

    Hey I didn't participate in the round, so don't know if this solution is correct. But maybe can help with intuition.

    Keep a count of number of chunks of 1s(c1) and number of chunks of 0s(c0). When we reach n/2 chunks each of 0s and 1s, we are done. In one operation if you reverse a sub-array starting and ending in different bits you can increase both c0 and c1 by 1 potentially (potentially coz that won't happen on the ends). It can be proved that while there are more breakable chunks of 0s and 1s there are sub-arrays ending in opposite bits that break these chunks, incrementing both c0 and c1 by 1. You may need one extra operation if you have an almost alternating sequence but with just c1 = n/2 — 1 and c0 = n/2 or vice versa. With this you can see that you will need max(n/2 — c0, n/2 — c1) reversal operations.

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

What is the intended solution of B and how to prove it? I... I just believe...

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

    consider the case 111011100000

    1**1101110**0000 : flip the selected part, it becomes : 1**0111011**0000

    101**110110**000 -> 101**011011**000

    10101**10110**00 -> 10101**01101**00

    1010101**1010**0 -> 1010101**0101**0

    the selected part in each step is from the first occurrence of 11 to first zero after all ones, which by flipping reduces consecutive 1s by 1 and eventually become zero. So, the answer would be no of 1s for which (a[i]==a[i-1] && a[i]==1).

    Same goes for 0 as well and minimum of those two will be the answer.

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

If I submit two solutions for the same problem, first one can be hacked while the second one can't be. Then if after the 12-hour hacking phase, the first one gets hacked but second one is still is accepted, will my second submission be considered for total score or not ?

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

Yay solved A, beware CF for when i become red

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

nice testcases...

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

I wish I could ask "how to solve G?" instead of "how to solve A?" :) anyway, How to sole A?

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

    if((2*l)>r)-YES else-NO

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

      but why?

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

        We are basically trying to exploit the fact that for all m>n, n % m =n. Let us say l=14 and r=26

        We have to find a number x such that it gives a no larger than or equal to x/2 for all numbers from l to r, modulo x. Like 14 % x => x/2 .. 15 % x >= x/2 , up to 26 % x >= x/2 . It is clear that the number should not exceed 2*l , as on taking modulus, any number x larger than l would return l itself. Hence after x=2*l, l itself will give a remainder smaller than x/2.

        If by any means, the number r lies beyond 2*l ; we are certain there exists no solution x , as l % x < x/2 i.e. l < x/2 .

        P.S. In the above example, 28 would be an optimal answer

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

    Lets assume that $$$l = \frac{a}{2}$$$, now $$$a=2l$$$.

    If $$$(a \gt r)$$$, we know that all elements in $$$(l,r)$$$ are greater than or $$$\frac{a}{2}$$$ as $$$l = \frac{a}{2}$$$, therefore whatever the customer buys, he will have to buy $$$a$$$ cans which is what we wanted so answer is YES. If $$$(a \lt =r)$$$, He can just buy $$$a$$$ cans and he doesn't need extra cans as $$$a$$$ lies in $$$(l,r)$$$.

    Why assume $$$l = \frac{a}{2}$$$? Because it is optimal and it gives us the biggest window.

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

Did anyone solve problem C, greedily ?

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

The key education that I seem to get from these Educational Rounds is how to get my ass kicked. How did people go about spotting the pattern for B — tried so many approaches but none of them worked.

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

Can anyone please explain me why greedy will fail on problem C.

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

Hello for question D I used a greedy approach which I have seen others use. But my code WA and I have no idea why. Can someone please look: https://mirror.codeforces.com/contest/1437/submission/96922858 ? Thank you!

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

Can anyone please explain me why greedy will fail on problem C.

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

In problem e : "In one operation, you may choose two integers i and x (1≤i≤n, x can be any integer) and assign ai:=x. This operation can be done only if i does not belong to the set b." in the first example :

7 2

1 2 1 1 3 5 1

3 5

So I understand that I can never apply such operation on the elements with indices 3 and 5. So a[3] = 1 for always. Why the output is not -1?

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

Did someone else solve C in O(N*logN) with the solution for 713C in this blog? Thanks zscoder for such a useful trick.

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

in problem A possible a always be r + 1 ? why..

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

Here's a more formal explanation of solution to problem B. Let's say you need to make the input string S equal to T 101010.... The procedure for converting a string equal to the other target string i.e. 010101... is quite similar. Now, let's xor our input string S with the target string T. Say this string is R. It's easy to analyse that R shall have even number of ones. Now, reversing a substring in S is equivalent to reversing the same substring in R. Also, on reversing a substring of even size, with all ones, changes all the ones to zeros. So, basically, the best strategy for us is to bring all the ones closer to each other and then use one operation to change all ones to zeros. Thus, the ans is number of blocks of consecutive ones in R

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

C has a greedy tag too. How to solve it greedily?

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

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

How to approach C with DP?

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

    First sort all the dishes in increasing order, then define dp state as dp[i][t] = the minimum unpleasantness possible in taking out the first i dishes in that order within time t.

    There are two possibilities here:

    1. You can take out dish i at time t, in that case dp[i][t] = dp[i-1][t-1] + abs(t[i]-t).

    2. You don't do anything at time t, in that case dp[i][t] = dp[i][t-1].

    Pick the minimum of these two.

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

https://mirror.codeforces.com/contest/1437/submission/96883973 https://mirror.codeforces.com/contest/1437/submission/96876758 please check ... those submissions are doubtful. i think, it's a Plagarism case.

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

What is the expected time complexity for F? My solution works in O(NlogN) (only because of sorting) and I don't realy know how to solve this problem with different aproach, but N<=5000 and time limit is 4s.

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

    That's really interesting, can you describe your solution? My solution (which is the model one for this problem) uses dynamic programming with $$$O(N^2)$$$ states.

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

      Оно немного непонятным может быть, поэтому я лучше на русском)
      Я писал дп с N-1 состоянием, где dp[i] — количество способов расставить первых i рыбаков, если мы уже както *хорошо росставили остальных n-i рыбаков. Сразу стоит сказать что если a[n-1]*2>a[n], то ответ 0.

      Теперь, как мы пересчитываем dp[i]:
      Если мы хотим поставить a[i] на первую позицыю, то для начала надо росставить все числа от L[i]-того до (i-1)-го надо поставить на любые позицыи кроме первой(L[i] — такое минимальное j, что a[j]*2>a[i]). Количество способов ето зделать — (n-i)*(n-i+1)...*(n-L[i]-1). А теперь нужно еще росставить числа от 1 до L[i]-1, при том что мы уже *хорошо росставили тех кто от L[i] до R[i], а ето по опредилению — dp[L[i]-1].

      И еще мы можем не на самую первую позицыю ставить, но тогда количество способов ето зделать — (n-i)*dp[i-1]. Вот решение с етой идеей, но произведение я тут считал, так сказать, в тупую, так что там O(N^2) 96921154. А вот уже за линию — 96930477. Если непонятно(а скорее всего, учитывая что писал ето я — непонятно), я постараюсь ответить на вопросы.

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

    Very cool. I haven't yet read your solution in detail, but I believe that the model solution that BledDest mentions with the $$$N^2$$$ states is this:

    Let's first sort the numbers. For every person $$$i$$$, we know that there is a certain prefix of people such that each element $$$j$$$ of the prefix has $$$2*a[j] \lt = a[i]$$$. These people can freely be placed once person $$$i$$$ is placed, since they are guaranteed to become sad due to $$$i$$$. Let' call this the sad prefix of $$$i$$$, and say it has length $$$pref[i]$$$.

    Let $$$dp[i][j]$$$ represent the number of (suffix of) emotional sequences which start with person $$$i$$$ and $$$j$$$ elements from the sad prefix of $$$i$$$ has already been used. That is, they must not appear in the generated sequence once again.

    The transitions can now be writted as: $$$dp[i][j] = (pref[i]-j) * dp[i][j+1] + sum[suf][j+1]$$$

    Here, $$$suf$$$ represents the least index of any element with value $$$ \gt = 2*a[i]$$$. $$$sum$$$ maintains the suffix sum of the DP.

    This works because we can choose to select one of the available items in the sad prefix and then the remaining sequence generated will be $$$dp[i][j+1]$$$, or we can choose to continue to another number which will be happy.

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

Is there a greedy solution for problem C? If no can you prove it?

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

Editorial when?

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

Who else is waiting for editorial ???

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

Hi all I am unable to construct a case for which my code for problem D fails. Can anyone please help? Link to submission: https://mirror.codeforces.com/contest/1437/submission/96924627

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

.

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

B's solution was leaked on telegram . Cheaters pls go to codechef long challenge ;leave codeforces.

PS:I saw it after the contest.
»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

can anyone help me in test 12 in problem E, I want a smaller case to see where the wrong is

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

can someone help me in testcase 12 in problem E, I want a smaller case to see where the wrong is.

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

Wow A and B, especially B were a lot trickier than i expected...

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

Since nobody has said this yet — I have used Hungarian algorithm for C.

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

Suppose we have alternate problem for A. That is, only customer who visited are L and R. then what will the solution?

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

    I only come up with an $$$O(\sqrt n)$$$ solution.

    Note that $$$l\%a = l - \lfloor \frac l a \rfloor * a$$$, thus the constraints become $$$l \geq (\lfloor \frac l a \rfloor + \frac 1 2) a$$$

    Now we can see for those $$$a$$$ that $$$\lfloor \frac l a \rfloor$$$ are same, you only need to consider the smallest $$$a$$$.

    For a fixed $$$l$$$, $$$\lfloor \frac l a \rfloor$$$ only have $$$2\sqrt l$$$ different values.(You can find proof and the way to iterate here) So there are $$$2\sqrt l + 2\sqrt r$$$ possible $$$a$$$, just iterate through all of them and check.

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

Drastic increase in competition on codeforces:- I just feel that in these days who have rating around 1700 would definitely be a candidate master around 8 months back, And now a days becoming a expert and retaining it becomes difficult.

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

Could anyone tell why is this logic getting hacked for the 1st problem ? HERE

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

Stupid hacking question: If I open a solution and do not do anything after looking at it, will I lose points?

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

What makes you instantly feel that problem C is a dp problem? (Except the constraints).

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

How will the graph for problem D look like for this test case :

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

https://mirror.codeforces.com/contest/1437/submission/96958667

can anyone suggest me a correction for my code. for A

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

96923678 1:57

96925007 1:59

I found 2 contestants with the same code

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

When will the ratings be updated??

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

Anyone explain how to solve E or explain the solve function in this submission 96887072?

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

how to solve D? https://mirror.codeforces.com/contest/1437/submission/96974806 on what test case my solution fails?

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

Can anyone please explain the jiangly's solution for problem C 96873242? He used only one state ( dp[n] ).

Update: After the explanation from comments below, I think the idea is during the i'th itereation, dp[j] stores the minimum value to place j elements before time i. In next iteration, For updating dp[j] we only need value of dp[j-1] of (i-1)'th iteration. (And since we are going right to left dp[j-1] will contain the value corresponding to time (i-1)).

Therefore, Transitions:
dp[j] (value to put j elements till i'th time) = min (dp[j] (placed j elements during (i-1) time) , dp[j-1] + abs(t[j-1]- i))
cost of placing j'th element ( 0 based indexing in t) at i time.

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

How to solve C using flows?

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

I am not understanding which it is happening this or not that in first question my offline compiler"visual studio code" is giving differenet answer than that of codeforces compiler.

Can anybody help me out in this.

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

Terrible contest

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

Can someone explain me how to do C. Thanks:)

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

deleted

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

My unofficial editorial for this contest.

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

Now i am doubting if this round is rated or not?

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

can someone tell me why max time is 2*n In question C ?

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

    Edit: I initially misread the query.

    Think of the following case.

    $$$t_1 = t_2 = ... = t_n = n$$$

    It is optimal to take out the last dish at $$$t = 2n-1$$$. If you go further, you are guaranteed to leave unnecessary empty time slots behind.

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

    Consider the one dish with the smallest t[i] value. It is never optimal to take that one out of the oven after t[i]. Because if we would do, a better solution would be to take it out one minute earlier.

    So, consider the next smallest t[i_2]... again, it is never optimal to wait after t[i_2]. By induction follows that it is never optimal to take out the last one later than 2*n.

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

      hmm gotcha ! btw do you suggest writing forward Dp(updating yet-to-come states on the go) or backward dp(updating previous states on the go) ?

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

        I do whatever seems simpler to me. That depends on the problem statement.

        For complecated dp I find it most often simplest to have a function that gets all state as parameters and calls itself recursive. Then add memoization.

        Once that code is written it is often simple to write the imperative code as well.

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

When will the tutorial be uploaded?

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

is it rated??

If yes, when rating is going to updated??

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

Tutorial and rating should have been updated by now.It is way beyond limit

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

The problem D could be solved using Two pointers as well.In my below AC code , cnt0 is for cnt of the nodes of height=cureentheight-1 which has no child. And Cnt1 is for cnt of the nodes of height=currentheight which has no child. Here is my solution https://mirror.codeforces.com/contest/1437/submission/96985177

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

where is the editorial....its too late

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

This is the first time I turned blue, a memorable game! Hope everyone can have good luck and high rating!

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

For Problem C, If there is a single dish and its cooking time is say 50, shouldn't the answer be 0 as we can just wait and take it out at 50th minute? Why is it not the answer?

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

easy contest I dominated it in 10 minutes