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

Привет, Codeforces!

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

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

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

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

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

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

Также от наших друзей и партнёров из Harbour.Space есть сообщение для вас:

Codeforces and Harbour.Space

Привет, Codeforces!

Пришло время для еще одной отличной возможности получить стипендию от Harbour.Space!

Мы стали партнерами PhazeRo, чтобы открыть двери для увлекательной карьеры в сфере технологий для самых талантливых людей.

В сотрудничестве с PhazeRo, мы предлагаем полную стипендию для обучения в магистратуре "Data Science" в Harbour.Space, во время которого вы будете проходить стажировку на позиции Junior Data Scientist в PhazeRo!

Условия для получения стипендии:

  • Степень бакалавра
  • Свободное владение английским языком
  • Знание интеллектуального анализа данных, математики и статистического анализа
  • Опыт работы с Tableau, SQL, и разными языками программирования (а именно Python, R, Java)

О стипендии:

  1. Учеба в самых интересных технологических городах Европы
  2. Размер стипендии до 22,900 евро
  3. Компенсация за стажировку в PhazeRo (700 евро в месяц)
  4. Возможность работать в PhazeRo на полную ставку по окончанию обучения

Codeforces and Harbour.Space

Некоторые из преимуществ работы в PhazeRo:

  • Возможность трудоустройства по окончании учебы
  • Погружение в атмосферу работы в международной компании
  • Программа поощрения многообразия
  • Профессиональное развитие
  • Станьте частью компании, которая создает самую большую техническую команду в регионе.

Ранее мы сотрудничали с другими компаниями, такими как OneRagtime, Hansgrohe, Coherra, и Remy Robotics, чтобы расширить возможности молодых талантов по всему миру и помочь им сделать карьеру в сфере высоких технологий.

Мы всегда рады видеть членов сообщества Codeforces, которые присоединяются к семье Harbour.Space. Подайте заявку сейчас, чтобы получить шанс учиться у лучших в этой области и начать свою карьеру!

Следите за новостями в LinkedIn, чтобы не упустить новые возможности. А так же загляните в наш Instagram, где мы делимся событиями студенческой жизни и историями успеха наших учеников.

Удачи в вашем раунде и до встречи в следующий раз!

Harbour.Space University

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

Место Участник Задач решено Штраф
1 neal 6 186
2 vepifanov 6 188
3 Um_nik 6 251
4 Farhod 5 65
5 noimi 5 76

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

Место Участник Число взломов
1 __ZMF__ 50:-50
2 mufeng.wei 24:-4
3 SSerxhs 22:-9
4 siriusscoder 13:-1
5 haminh0307 11:-5
Было сделано 463 успешных и 1684 неудачных взломов.

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

Задача Участник Штраф
A Geothermal 0:01
B turmax 0:02
C eecs 0:04
D abc864197532 0:04
E noimi 0:28
F rainboy 1:16

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

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

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

I hope I get that scolarship ...

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

Надеюсь решу больше чем только А :)

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

I think preliminary rating change in educational rounds will be great.

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

9th rated contest of the month. Hail Codeforces!

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

A long break bruh, Codechef also postponed the Lunchtime.

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

i am very excited to participate the contest,wooooooo~

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

Almost every edu round I was "educated", but I still participate in every round...

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

"The penalty for each incorrect submission until the submission with a full solution is 10 minutes"

Does this mean that only time will be taken and there wont be a -50 or -100?

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

Today codeforces educational round. Tomorrow codechef lunchtime. Day after Tomorrow CodeJam Round 1C. Practice & Compete & Improve.

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

hope i remain expert after this contest :)

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

Time to start the vacations with an educational round. Excited!

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

I wish B/C not to be a observational shit like printing the array upto k and then upto n-k lol.

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

Hakcers will try to hack the solution in 12 hrs, while cheat busters will try to match the solutions in 12hrs.......

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

i hope i do best in the contest and happy coding to everyone

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

Have a great rating change

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

Nice contest!

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

Today's Problem Difficulty. Pls forgive me for not enlarging the image as I dont know how to do that.

Today's Problem Difficulty

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

sometimes unexpected bruteforce works . Today it worked for problem C for me

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

Speedforces

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

Does anyone with O(2*n^2) space got MLE in D?

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

Memory limit was too short for problem D!

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

Probably there's like around 5 people right now writing "SPEEEED FORCES"(joking of course:)). I think this problem could have been avoided if E was more "div2-solvable", I mean around 60 people solved it and a good amount of them are red coders. There's no point I think in making A-D so standard(especially D) and E that hard.

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

    Pretty crazy variance. Solving A through D could either get you 60th place (with an implied rating of about 2250 according to cf-rating-predictor, which is orange), or as low as 2400th place (with an implied rating of about 1640, which is blue).

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

Really liked $$$E$$$. I wonder if everyone solved it the way I did.

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

    Interesting. I just used a known algorithm, which is given a graph cover it with paths of length 2 using a DFS. Seems most other people did it this way as well.

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

      Can you describe said algorithm? I wasn't aware of it's existence.

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

      Interesting! I didn't know about this algorithm.

      As I understand (after reading the Editorial to the task dorijanlendvaj posted), to apply this algorithm you transform the task in the following way: Each line through the origin will be a node. Each Point will be an edge and it connects the two lines to which it can be moved. Now we want to find edge-pairs which are connected to the same node. Those pairs should be mutually disjoint.

      While I was thinking about this problem I somehow was only thinking about the other way round: For me each point was a node. Two nodes are connected, if the corresponding points can be moved onto the same line through the origin. Now I tried to find the maximum amount of disjoint node-pairs connected by an edge. (This is the Line Graph of the first interpretation).

      So what I learned: Sometimes you should switch edges and nodes in your analysis/interpretation of a problem, maybe this will make the problem easier.

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

        If we consider the points as vertices and connect two vertices iff they'll lie on the same line passing through origin after shifting them. Then this problem will reduce to finding maximum matching in the graph, right? But that is too general. As in our graph let's say a is connected to b,c,d then a is a part of at most 2 cliques which is ({a,b,c,d}) or ({a,b},{a,c,d}) , or, ... etc .

        So by considering a line as a vertex, we have somehow used this property, right?

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

          Hey Zura,

          Theanks for pointing me to the maximum matching problem . That is exactly what should be solved in the second interpretation!

          Im not sure about your other comments though. Which property do you mean? I feel like we lose properties by looking at the linegraph, because the problem can't be solved with a simple DFS anymore.

          Maybe it's good to look at an example? e.g. {(1,2),(2,3),(3,4),(4,5),(5,6),(1,6)} (The first 5 points all can be moved on the main diagonal, and the 1st and 6th point can be moved on a common line) would have those two graphs in the corresponding interpretations:

          Image

          The possible solutions are the same in both cases. Could you explain again what you meant, possibly with the example (or an own example)?

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

            1st and 6th can't be moved on the same line as the first ones' slope would be (2+1)/1=3 and for 6th it is (1+1)/6=1/3.

            Other than that as I was pointing out 1,..,5 forms a clique.

            If 6th point were (2,5) and 7th were (3,8) then 1 is contained in two cliques 1,..,5 and 1,6,7. So by considering when we use a line as vertex we are basically accounting for this whole clique.

            I am unable to understand any further than that though, so waiting for the tutorial.

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

        Why switch if you reduced problem to kuhn-munkres algorithm? You mean that you could do better with dp than O(n*m)?

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

          No, The property that I stated in the previous comment, at most 2 cliques, will help us as we have not utilized all the components of the problem. I don't know how to model this property, but these additional bits help us, and hence we can do better than Blossom's as that is for general graphs.

          Blossom's is for general graphs.

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

          Could you elaborate? Do you mean kuhn-munkres ? This sounds to be an algorithm for bipartite graphs, but the second interpretation doesn't yield a bipartite graph.

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

            Yep, you are right. My mistake.

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

              You can use the Blossom Algorithm though with $$$O(V^2E)$$$ or $$$O(\sqrt{V}E)$$$ with "the much more complicated algorithm of Micali and Vazirani".

              Guess we should stay with the first interpretation, or somehow use the information that the graph in the second interpretation is a line graph of some other graph (of the first interpretation).

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

                Couldn't get it when I read it first time, (an0nym0us_m0use, czhang2718) but now I think I understand :) Looks like it will really work greedily with every connected component as stated above: While doing DFS on a graph until you met visited vertex or deadend-vertex, then you come out of current vertex and connect all unconnected pairs of children (those that were left unconnected when you left them). And if there 1 left — you connect it to current vertex, else — you return in to it's parent as "unconnected" yet. Then parent repeat the process. And the number of unconnected points in answer will be the number of even-numbered-components.

                And that will work for any of two graphs. It's nice that they delayed editorial :)

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

                  Yes exactly that! I also did my submission 114692979 that way and it got accepted right away. The DFS-logic is in the "dfs" method and does exactly as you explain. :)

                  But what do you mean with "any of two graphs"?

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

B destroyed my confidence.

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

Could we solve D with $$$n$$$ times FFT? My $$$O(n^2 \log n)$$$ solution can't pass this TL :(

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

how to solve D

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

In E, I was able to group together the points that can be taken together in one move. But, how to make pairs? is it some sort of matching problem?

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

Video Solutions for problems A — D can be found here: Video Solutions

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

D was so easy compared to C

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

Nice problems

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

Is Question E a MCBM problem? I was thinking of modelling both of the possible moves as a fraction x/y then try to do matching between points with the one of the same fractions. However, this is potentially O(n^2) so I am not sure if there is a way to optimize it.

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

memory limit was too tight in problem D

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

I used n^2 Space to solve D but it exceeded memory limit. I still wonder how it is possible.

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

How to solve Problem C. I ran into TLE. This is my solution using Heap. I also tried using sorting the vectors, which too ran into TLE. Kindly help

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

Hi, Can someone help me with my submission for problem C . I am getting a run time error for the first test-case which is already given but running that test-case on my laptop is not giving any error and the output is also correct . The link to my submission My_Submission. Thanks in advance.

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

Problem D was super not Python friendly. This is the shit I did to get accepted 114611359.

The reason for the TLEs in Python is basically that PyPy2 and PyPy3 is only 32 bit on Windows. So on Problem D you are forced to use big integers everywhere, which is super super slow. However in the latest update of PyPy (version 7.3.4), PyPy switched to supporting 64 bit on Windows.

MikeMirzayanov Would it be possible to update the PyPy version (to version 7.3.4)? All of these issues with big integers would go away, and it would make PyPy a lot more useable and beginner friendly.

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

too strong memory limit in D (

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

In question C, the description was ambiguous, there were not exactly 'n' universities always, rather nothing should've been mentioned about universities!:)

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

Hello everyone, this was my first ever contest on any coding platform , and I was able to solve just 4 questions and got around 1500 rank. Can anyone tell me whether it is considered good performance or not? Also , what should I do in order to improve? Thanks a lot.

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

Why was B so easy? Usually B is twice as good as A(even for an edu round). We can basically induct on $$$m+n$$$ and B is solved.

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

Question regarding Problem B: How can we prove that no matter which path we take it will always result in the same cost of N * M — 1 ?

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

Can someone please explain the proof why for problem B, the answer is k==(n*m-1)?

I solved with DP and got surprised to see it could be formulated.

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

    Consider any RD from (x, y) to (x+1, y+1), you can see that changing the sequence to DR does not change the cost, and thus any sequence will have the same cost.

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

    Prove by induction. You can assume the proposition true for m×n grid , and establish for (m+1)×n grid.

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

    I did some few examples on paper and found out that the answer is unique, for every n, m. I couldn't find the formula so just calculated it step by step and checked the cost if it equals k.

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

    Proof for problem B that answer is k==(n*m-1).

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

    Another possible proof:

    Instead of it costing $$$x$$$ or $$$y$$$ burles, say that it costs $$$x+y$$$ burles and then you get $$$y$$$ or $$$x$$$ burles back.

    In each move, $$$x+y$$$ increases by 1 so the total sum of $$$x+y$$$ is $$$\frac{(n+m-1)(n+m)}{2}-1$$$, the total amount of burles you get back with the increase of $$$x$$$ is $$$\frac{n(n-1)}{2}$$$(you do one with each $$$x$$$ from $$$1$$$ to $$$n-1$$$) and the total amount of burles you get back with the increase of $$$y$$$ is $$$\frac{m(m-1)}{2}$$$(you do one with each $$$y$$$ from $$$1$$$ to $$$m-1$$$). In total the cost is $$$\frac{(n+m-1)(n+m)}{2}-1-\frac{n(n-1)}{2}-\frac{m(m-1)}{2}=nm-1$$$.

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

What is the meaning of the Problem B title?

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

Very happy to see some good ad-hocs like ABCD.

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

Только мне показалось, что системное тестирование с 0% до 99% дошло за секунду?

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

Screencast with commentary aka Um_nik staring at problem F for 40 minutes in silence

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

My python submission for problem C is getting TLE on Tc 5, I tried implementing it as the same way other people implemented and got AC. MY SUBMISSION FOR PROB C

please help. Thanks in advance.

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

I think the official generator for task E is broken since none of the 26 pretests have n > 1e5! Therefore, It'd be best if the authors cut the limit on n to 1e5 and rejudge all the solutions to respect the spirit of competition. awoo

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

This contest was actually educational for me. I learned 2 things: 1) Never trust the ceil function. 2) Don't write iterative dp like it's recursion, always check the order of computations... goddammit D.

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

I solved problem b but not able to solve a :(

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

Hey! In C problem, I was using comparator on a vector of vectors. When I used '>=' in the comparator it gave a runtime error while using only '>' gave the 'Accepted' verdict.

Runtime code : https://pastebin.com/WQwxwrCd

Working code : https://pastebin.com/sf1e1BTk

Both codes are same except on the 18th line where there is difference of '>' and '>=' in the respective codes. Can anyone explain why this happens?

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

How to get rid of MLE in problem B using Dp can anyone please help? Here is my submission 114621015

Thanks in advance :)

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

speedforces ;)

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

speedforces :P

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

Can anybody tell how to optimize my C's solution further ? 114617580

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

    There can be n lists of size == 1, but you'd still check every of them for i = [2..n]. That would be O(n^2) ~ 10^10. Kick them off from map when their len == i, and stop cycle when i > max_len(m[i]) (map should be empty at this time). But first kick those with len <=2.

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

I guess, the test cases were weak for problem C. Sorting the vector of vectors based on their size and stopping once the size becomes less than K can get your solution accepted.

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

    There's an explanation for that actually. If you iterate from each $$$k$$$ from $$$1$$$ to $$$n$$$, you will find at most $$$\frac{n}{k}$$$ vectors that have size at least $$$k$$$.

    That leads to a known sum which is $$$n logn$$$.

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

      There is a trick to even get it down to O(n).

          out = []
          for k in range(1, n + 1):
              teams = [t for t in teams if len(members[t]) >= k]
              score = 0
              for t in teams:
                  score += prefix_sum[t][k * (len(members[t]) // k)]
              out.append(score)
      

      This part will run in O(n) time, not O(n log n). This is because a team with $$$m$$$ members will be filtered out of teams after $$$m$$$ iterations. And since the sum of the sizes of all teams are $$$n$$$, the code runs in O(n) time.

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

    This is probably the intended solution and it's $$$O(nlogn)$$$. It's not about the test cases, it is indeed $$$O(n)$$$ except sorting. Because, if done so, we will consider a university with size $$$s$$$ in only $$$s$$$ different $$$k$$$'s. Since the sum of all $$$s$$$'s is $$$n$$$, complexity is $$$O(nlogn+n)$$$, that is, $$$O(nlogn)$$$.

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

Please explain how to make problem C using Two points method, i made it using Prefix sums.

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

    I guess you'll need prefix sums anyway. From now on, assume that the universities are sorted in non-decreasing order by size. The thing with the "two pointers" must be that when you encounter a university with size smaller than current $$$k$$$, you have to move your "left pointer" (you shouldn't evaluate universities on the left of the left pointer because their size are smaller than $$$k$$$). As with the right pointer, it just doesn't exist.

    P.S. : It is my understanding of this tag.

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

How to solve D?

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

Can someone explain why the first submission gets TLE while the second one gets accepted?

114581044 114630025

Only difference is how I sort a vector.

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

How to solve C ? I solved using factorization in O(nsqrt(n)) but it seems lot of people have solved in some different way.

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

    idk

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

    You can solve problem C using Prefix Sums . Divide all the students by their corresponding cities . For each city , if number of students in my current city is $$${m}$$$ and size of teams is $$${k}$$$ , then $$${m\%k}$$$ lowest skilled students will be not be in any team .$$${\newline}$$$ So for each city , sort the array of students ,calculate the prefix sums , and then iterate over the size of teams ($$${1}$$$ to $$${m}$$$ ) , take sum of skills of all students who can be teamed up ( $$${pref[m]-pref[m\%i]}$$$ ) and add to the final answer array .
    Hope it helped !
    Submission Link : https://mirror.codeforces.com/contest/1519/submission/114643205

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

      So, let say there are $$$n$$$ university and each university has only $$$1$$$ student then don't you think your solution will be $$$O(n^2)$$$? I was trying to do same but this case stuck in my mind

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

        The the number of students is $$${n}$$$ , the only thing I did is distribute those $$${n}$$$ students across the cities . There are two loops but the sum of total operations of the inner loop is still $$${\mathcal{O}(n)}$$$ (because I am iterating over the students and only n students exist across all the cities ) .

        In your example case , the inner loop will perform $$${\mathcal{O}(1)}$$$ operation for each outer loop iteration , summing upto $$${\mathcal{O}(n)}$$$ . (Also you'll need to account for sorting , which takes $$${\mathcal{O}(nlogn)}$$$ ).

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

Speedforces.

Many people solved ABCD.

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

Need Help in problem D: **** I have solved Problem D using Python. i wrote the same logic in two different ways 1st way got Accepted but the 2nd way got TLE. both are exactly same as other only I changed the calculation part of the code and I believe it should not affect the run time. please help me out.

TLE Submission : https://mirror.codeforces.com/contest/1519/submission/114646999 Accepted Submission : https://mirror.codeforces.com/contest/1519/submission/114647073

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

weak test in C

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

Can anybody please tell me why i'm getting TLE in C? Like i used the same approach as many the people who got accepted did, till today morning my solution was accepted by now it's showing TLE
here is the link to my submission https://mirror.codeforces.com/contest/1519/submission/114596588

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

OH C ! You broke my little heart

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

Can Someone figure out why I am getting random values instead of 0, for problem C MyCode(https://mirror.codeforces.com/contest/1519/submission/114659037)

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

when the ratings update cannot wait for more time??

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

In Problem E, why doesn't the following greedy solution work?

I first order lines by their angles with Ox and iterate them by counter-clockwise order. For each line, find two points that can reach the line, and always take points under the line first. Of course, I remove selected points after each step.

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

    I did the same but got stuck on test 7 because there's a test case that ruins this approach. Let's say a specific angle has 3 points and other have 4 points and another one with 1 point. You're gonna choose any 2 of the 3 but what if the 2 points you choose were in the other 4 points ? It won't be chosen there (at the 4 points's angle). So, you have to choose 2 points out of the 3 that won't interfere with the 4 points to get the maximum number of moves and it would just interfere with that 1 point because it won't be chosen anyway. Hope you understand my explanation.

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

Time limit exceeded on test 8 :(

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

C was a pretty cool problem. Never seen anything like it, requires some thinking, yet not too difficult. Props!

Why not just pick n=2000 for D, so it can be solved in Python? Now I had to go back and rewrite my solution in C++ for no particular reason, just because the Python implementation barely times out. I actually thought it was a very nice problem other than that annoying detail.

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

Is it rated?

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

Problem C raises my doubt about how vector<vector<int> > works in different versions of cpp compilers. After calling push_back() for serveral times, sometimes the result is unexpected but sometimes it looks fine. It seems that this error is related to the version of the compiler. Could someone please explain why?

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

MikeMirzayanov Please update the rating change, please...

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

I've got a nasty bug in the implementation of D which gives WA on Test 27. Can somebody help me figure it out ? 114670308

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

Does anyone know why the rating change in the CF predictor is so different from the actual rating change?

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

hm? why so big delta between predictor and real rating changes?

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

Finally, after 14 months and 57 contests I have reached CM. Feels good :)

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

Why is the rating change so less than cf predictor?

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

How come CF-Predictor is showing +79 rating change but the actual rating change is only +48 for me while there are other accounts who have seen increase in their actual rating change :(

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

I think the positive delta is really low even after getting 2899 rank considering My previous ratings i should have got +120-130 but i only got +81. is it normal ?

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

About the ongoing discussion about rating predictions in cf-predictor being wrong, I'd like to say something. The ratings of the people I've checked (including mine) are not up-to-date, that's probably the reason why the calculations of deltas are incorrect.

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

Can anyone explain how did my code pass the tests on problem B? I accidentally wrote: int dp[102][102][250]; instead of: int dp[102][102][10100]; The submission: 114572709 The problem: 1519B - The Cake Is a Lie

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

    Your program used 102 as the size of the array instead of 101 so that you have some unused memory(1*102*250=25500>10000),so when you use index out of bound like dp[100][100][10000],the program actually use dp[101][40][...] without getting an Runtime Error.

    However,I think it will cause some reuse of the element,but I don't know how to hack it so far.

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

Why does my solution for problem C TLE in java?

My code is clearly O(n*log(n)) (the log is from sorting, O(n) otherwise) because when I reach k > than the size of a university I don't revisit this university just as other people (above) described. The exact same code in C++ gets AC. I know that Java is slower but usually in problems like this it should pass the time limit...

Java Submission: 114570376 CPP Submission: 114677079

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

Can anyone tell me why I'm getting TLE in the 8th test case in Problem C.

Here is my code:-

https://mirror.codeforces.com/contest/1519/submission/114668130

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

    Your last working cycle runs mx*n == n * n = 4*10^10 times, because in this test case it looks like there 200K students from only one university and you are checking n-1 empty universities n times.

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

    Consider a case where n/2 students are from university $$$1$$$ and the rest are from distinct universities. In this case, mx = n/2 and tmp = n/2+1. So your last loop takes O(n^2) time to run which exceeds the time limit.

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

Hello I'm new here. where can I find editorial for this contest? Thanks in advance.

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

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

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

Not in the top of the best hacker :(

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

Can anyone help me in identifying the mistake in Problem D , the approach is similar to longest palindromic substring. It is failing in the 11th test case.

Link to the submission: https://mirror.codeforces.com/contest/1519/submission/114709341

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

Can anyone tell me why I'm getting TLE in the 8th test case in Problem C.

Here is my code:-

My code

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

    The loop that's looping on the universities should start with the lowest possible greater or equal to K, I mean when K = 4 you shouldn't iterate over teams that has number of people less than K, unless if you do iterate over them it would be O(N^2) a time limit for sure.