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

Привет, Codeforces!

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

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

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

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

Задачи вместе со мной придумывали и готовили Роман Roms Глазов, Адилбек adedalic Далабаев, Владимир vovuh Петров и Иван BledDest Андросов.

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

А вот сообщение от наших друзей из Harbour.Space:

Hello Codeforces!

We are excited to announce that the Hello Muscat Programming Bootcamp registration is open! The camp will take place from March 9th to March 15th, 2019, and our early bird discount of 15% is going until December 15th!

This next edition in our Hello Programming Bootcamp will run in parallel with the traditional Moscow ICPC Workshop — both Bootcamps’ contests will be identical, and contestants will be able to see their position in the General Leaderboard. Every day, both camps will be competing simultaneously, 4,000 kilometers from each other!

REGISTER FOR THE BOOTCAMP

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

Место Участник Задач решено Штраф
1 waynetuinfor 7 190
2 nuip 7 226
3 ToTLeS 7 246
4 danya.smelskiy 7 252
5 998kover 7 272

Поздравляем лучших взломщиков:

Место Участник Число взломов
1 9646516 75:-20
2 interestingLSY 49:-24
3 niki4smirn 12:-1
4 katana_handler 11
5 marismmm 8
Было сделано 298 успешных и 565 неудачных взломов.

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

Задача Участник Штраф
A sorry_stefdasca_snsdsux 0:01
B KerimKochekov 0:02
C Golovanov399 0:05
D Golovanov399 0:09
E ko_osaga 0:25
F vintage_Vlad_Makeev 0:28
G tfg 0:09

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

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

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

Auto comment: topic has been updated by awoo (previous revision, new revision, compare).

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

Clashes with COCI #3

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

Yes, it is rated for Div. 2

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

Is D bipartite checking?

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

    yes

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

      Pls explain in detail.

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

        check if each connected part graph is biparite, for each part color verticles with i.e. red and black and calculate number of red verticles. Then the result for each part is 2**red + 2**(part.size() — red) [you can put two's either in red verticles or black ones]. Multiply all numbers for final result, put modulo If m =0 , put 3**n % modulo. See my submission

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

      For a long time I thought graph was connected. After knowing that in hurry I used addition principle instead of multiplication :(.

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

how to solve D ?

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

    If graph contain odd cycle, answer is zero as no valid assignment can exist.

    Otherwise, let us find 2-coloring of each connected component in graph. Say, x nodes are colored red while y nodes are colored black. There are exactly pow(2,x)+pow(2,y) ways to color this component. Take product of this for all components.

    Reason of pow(2,x)+pow(2,y). You need sum of edges to be odd. So, one of the value on edge is 2 and other value is either 1 or 3. pow(2,x) assume we assign all red colored nodes with either 1 or 3, giving pow(2,x) choices. Same for y.

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

    It can be easily solved with BFS. And I came up with it a long time later, but I couldn't solve it because of Memory Limit Exceed.

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

It took me 4 wrong tries to actually realize that author has not mentioned that Graph will be connected in Problem D :'(

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

For those wondering about high submissions for G, You might find this problem interesting :)
MDIST

Can anyone share their idea for E and F?

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

    let's say p2[x] is position of x in second permutation, then you need to find number of l2 <= p2[i] <= r2 and l <= i <= r. It's easy to solve it with bit and sqrt decomposition.

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

      Wouldn't the complexity be n*root(n)*log(n) as for each block we need to find out how many values are there lying between l1 and r1, Also, if we use merge sort tree, we can reduce the complexity to n*log^2(n) as the problem is effectively calculating the no. of numbers that are between l and r in a particular range.

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

    In problem E you have to divide both permutations to blocks of length sqrt(n) and than make some calculations.

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

    My idea in E was creating sqrt(n) segment trees, so each of them contains a number of elements in the segment in the array b, that exist in according sqrt-bucket of the array a (t[s][l..r] — number of elements that exist both in in segment a[s*sqrt(n)...(s+1)*sqrt(n)] and b[l...r]). So it should have been some sort of sqrt-decomposition on segment trees.

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

    In the problem MDIST for 2-dim , we have to use 4 segment trees. But since in G there are more than 2 dimensions we have to use 2^k segment trees where k is dimension of the point. Is there any other way to do this problem?

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

I got a couple of wrong answers on D because I had mod = 1e9+7 saved in my template and forgot to change it to 998244353, and when I finally realized the mistake I corrected it in the last 10 mins. For those who say what's the use of setting mod to such a weird value its for people like me :-p

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

How to solve C? I made a great effort to solve it by using greedy algorithm only to get a wrong answer on #9.

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

    Yours approach looks correct.

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

    It's how you approached it.

    I did like this: split array a into halves, start filling from the middle of a (i.e. from right to left of array b).
    Denote the element b[n / 2] as x, the two middle elements of a will be x div 2 and x - x div 2 respectively.
    For the next elements, let's denote the ones we need to fill in the left half and the right half as L and R respectively. Also, we have MinL as the minimum of filled numbers in the left half, MaxR as the maximum of filled numbers in the right.
    Obviously L ≤ MinL and MaxR ≤ R. From there, you can easily split the element from b into two most optimal halves that satisfies both inequalities above.

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

    I did the same mistake :( So, now I have made a macro with int as long long.

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

I liked D. So, for any edge (u, v) exactly one of the nodes will have value 2.

If the graph has odd length cycle, then its impossible. Otherwise, simply do a black-white coloring of the graph. Now let # of black nodes be B.

Then in one case you can write 2 in B nodes, and the rest N-B nodes will have 2 options (1,3). In second case you can write 2 in N-B nodes, and the rest B nodes will have 2 options (1,3).

Ans = 2^B + 2^(N-B)

Code: https://ideone.com/2YmsN5

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

    Damn it!! I know understood how people solved this question in around 5 minutes. Nice one!

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

    Technically i think this is incomplete, it never says that the graph is connected. So use this solution for every connected component, and then multiply the solution of each one.

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

      Correct. I added that in the comments in my code. I was just highlighting the idea behind problem.

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

    Why this is giving TLE for a trivial case although I've implemented exactly this approach. code
    UPD: removedmemset() and it ACed :)

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

Are there faster solutions than Nlog^2N in E and Q*(2^K)*logN in G? Got TLE on both.

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

Problem D is pretty good ^^

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

For E, I couldn't pass a segtree of ordered_set in 6s. Is there any other better solution? Or it was just intended that we use BIT instead of segtree.

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

    Same here. After writing all that and getting TLE:

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

      I was doing with the same approach but could not complete coding. I think i would also have got the same verdict. :-p

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

    solve problem in offline: ordered_set -> BIT

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

    You can pass all tests with naive solution if you want in 5 seconds

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

      Why do you use alignas in your code? This is the first time that I'm seeing this.

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

        With alignas(32) pointer to array beginning will by dividing by 32-byte, or 256-bits. It allows GCC to use assembler command vpmaskmovd with AVX2 extension. You can read about vpmaskmovd (_mm256_maskload_epi32) this. So it needed only for fast loading to 256-bit cpu registers from memory.

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

          This is super interesting (and impressive). I have some followups:

          1. So I assume that it always makes sense to use alignas(32) before every array declaration? (One side question, it doesn't help to add that before a vector<int> declaration does it?)

          2. Do you know any other (hardware) tricks like this?

          • »
            »
            »
            »
            »
            »
            5 лет назад, # ^ |
              Проголосовать: нравится +5 Проголосовать: не нравится
            1. In case with vector you need to write own class aligned allocator and put it in vector template parameter.

            2. No, I know only about alignment. C++ has operator alignof(type) like sizeof(type).

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

    It's kind of unfair that the problem setters kept TL so tight that this is happening.

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

    Do you mean a merge sort tree?

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

Am i wrong or O(m * log^2) solution should get TL.

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

Problem D: when m==0 why the hell ans = 3^n ?? (-_-)

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

    Because every assignment is correct in this case — the constraint is vacuously satisfied. We get 3N as the product of possible assignments for each node, which is 3 (1, 2, 3).

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

has anyone done E with Bitset ? I got TLE at testcase 13

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

What will be the Rating of problem D?

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

Why did this get TLE?

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

    Never mind, just got accepted. Never thought memset would pose a problem though.

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

      Same problem tle due to memset. Would never use it again ;)

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

        I think memset is still quite important sometimes. Just need to evaluate better next time!

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

          memset() time complexity in your code is O(MAXN) and you do it every test cases giving total time complexity O(T * MAXN) with T = 3*10^5 and N = 1 for every cases, the code will definitely TLE.

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

            Thanks but I already figured it out before getting accepted lol

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

Check my submissions if you are looking for challenging hacks. You have to complete 4 funny tasks. Good luck :)

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

    Actually your C is not hackable since the corresponding rand() sequence does not correspond to a valid input sequence (since you should be able to form some sequence a1, ..., an out of it per the problem statement).

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

      The random sequence b is increasing therefore it is possible to make sequence a.

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

        That is not a sufficient condition. What is a sequence corresponding to n=4, b = [2, 100]?

        Here is the random sequence for your code. Validator doesn't accept it.

        40
        42 18468 26335 36501 49170 55725 61479 79359 86963 94465 105706 118146 123282 136828 149962 150492 162996 171943 184828 195437
        
        • »
          »
          »
          »
          »
          5 лет назад, # ^ |
          Rev. 3   Проголосовать: нравится 0 Проголосовать: не нравится

          You are right. I should have made decreasing array. Sorry for it. I uploaded the correct code. 47077025 Thanks for noticing and congratulation for the hack. If anyone else wants to hack: 47077601

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

    I'm quite confident your C is impossible to hack because it must be possible to recover the array from the input, but having your array as input doesn't correspond to any array from the task.

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

I had the same sqrt(N) blocks idea for E but ended up with memory limit exceeded. Did I derp too hard or was there something I'm missing? I had a 450 x 200005 int matrix at most

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

What's the hack for problem D?

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

My accepted solution for problem E in O(n * m) time works 5225 ms.

Can anybody hack it? Maybe halyavin?

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

Can anyone tell me, why i am getting compilation timeout???submission

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

Solution for F?

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

halyavin is coming!!!

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

halyavin is coming!!!

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

I've just started using CodeForces and this was my first contest (and I got 2 accepted solutions). Can someone tell me:

why I still dont have a rating ? Will my profile be updated later (after few hours) ?

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

    There is hacking phase after Educational rounds which lasts for 12 hours then the system testing will begin, it takes around an hour. after all of this your rating will be changed.

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

      Wasn't System Testing done before the Hacking Phase? If System Testing has not started, the competition status will be displayed as 'Pending System Testing'. However, the current state of the competition is marked 'Finished'.

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

        No, it was the judging of the late solutions that were submitted on the last seconds.

        after the hacking phase, all of the solutions will be rejudged with the complete testset not only the pretests (this is the system testing).

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

      Thanks @Khaled_Mohamed !

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

47050528 hey, this is the fisrt time i am competing. Can anyone explain me whats wrong with this code for first problem.

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

    You were doing a wrong greedy.

    Since the constraints are pretty small, you can just brute force the answer: an answer i will be considered correct if 2i ≤ x ≤ 7i.

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

    When input is n = 29, your code doesn't give any output!

    After this step:

    std::cin>>x;
    rolls=x/7;
    x=x%7;
    

    'x' becomes equal to '1' and it can never become '0' in below mentioned conditions from your code:

    rolls=rolls+ x/6;
    x=x%6;
    rolls=rolls+ x/5;
    x=x%5;
    rolls=rolls+ x/4;
    x=x%4;
    rolls=rolls+ x/3;
    x=x%3;
    rolls=rolls+ x/2;
    x=x%2;
    

    So it doesn't print the output at this step:

    if(x==0){
         printf("%d\n",rolls);
    }
    

    PS: Think easy :)

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

Can anyone please tell what is wrong in this solution for the problem D code

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

Can anyone explain the solution for problem C? I can't understand why we r taking a max of b[i] and b-a[n-i].

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

    a[i]=max(a[i-1],b[i]-a[n-i]) would ensure that a[i]>=a[i-1] which means that sequence is increasing and also a[i]>=b[i]-a[n-i] which means a[n-i]>=a[n-i-1].

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

Can someone please point out why do I hit a time-limit-exceeded on test 2 with this submission?

https://codeforces.com/contest/1093/submission/47082541

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

    Graph doesn't have to be connected. Here is example: n = 3 * 10^5, m = 0 Then this part:

    Spoiler

    will take n^2 time. Another bug in your code is in this line:

    ans += (1 << red) % MOD + (1 << black) % MOD;
    

    black and red can be bigger than 64. Better option is to just count every 2^k % MOD at the start of your program:

    POT[0] = 1;
    for (int i = 1; i < N; i++)
        POT[i] = (POT[i - 1] * 2) % mod;
    
»
5 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

How to solve E?

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

    My way to solve this problem (not very efficient, but it passed):

    Represent each number as a point , then the problem will become count the number of points in the rectangle with two opposite vertices (la, lb) and (ra, rb). You can easily solve this problem with compressed 2D BIT.

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

Can anyone explain solution to E with ordered statistics set? I saw few codes that get AC but I don't understand them all. And what does this magic loop:

for(int i = x; i <= n; i += i & -i)
»
5 лет назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

Can anyone figure out why my program will get many negative outputs in problem D? 47086094

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

    a *= a % c means a = a * (a%c), which is not a = (a*a)%c, so it will overflow.

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

i missed this -_________-

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

anyone solved D with DP ??

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

    But why?

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

      because i doesn't know the coloring in graphs

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

        It's pretty straightforward. You can use graph traversing algorithms of your preference (BFS or DFS) and just change used[] array to color[] array. You only need two colors for this problem. Then assign all children with a different color of its parent. Also, check that no neighbours have the same color (it is only possible if you have a cycle of an odd length).

        As for DP, I have no idea how such a solution would look like, but it probably would be an overhead.

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

Will there be an editorial?

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

Will there be an editorial?

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

Can anyone help me with my code for D. I'm getting TLE for test13 My Submission

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

where is the editorial??

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

The idea behind E's solution is good. You have to choose such a block size such that n*(block_size+log(n)*n/block_size) is minimised. It is not necessary that optimal block_size is root(n),

PS: E passes with block_size = 3000.

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

I am pretty sure that problem F is the exact same problem as 204D - Little Elephant and Retro Strings. but instead of using only 2 values he uses k.

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

Auto comment: topic has been updated by awoo (previous revision, new revision, compare).

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

Can anyone tell me what am I doing wrong in part D.

link : https://codeforces.com/contest/1093/submission/47249694

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

If there is a single vertex in a component, should we add 2 or 3 in problem D?