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

Привет, Codeforces!

В такой замечательный день недели, как 18.08.2018 17:35 (Московское время) состоится Educational Codeforces Round 49.

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

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

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

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

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

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

Hi Codeforces!

Our Hello Barcelona Programming Bootcamp will be kicking off next month from Sept 26 — Oct 4, and we’d love to see you there!

The boot camp will once again feature the all-time greats Mike MikeMirzayanov Mirzayanov, Andrey andrewzta Stankevich, Michael Endagorion Tikhomirov, Gleb GlebsHP Evstropov, Artem VArtem Vasilyev, Ivan ifsmirnov Smirnov and other world renowned Russian coaches to train the participants.

You will be competing and learning side by side with some of the greatest teams in the world, while learning from the best coaches the ICPC has to offer.

Be sure to register before September 1st so everyone has time to get visas if needed, and of course for the Early Bird Discount of 5% or the Loyalty Discount* of 20% off registration for the boot camp!

*The loyalty discount is offered to universities and individual participants that took part in Hello Barcelona Bootcamps and Moscow Workshops ICPC.

Learn more about Barcelona ICPC Bootcamp

You can ask any questions by email: [email protected]

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

Место Участник Задач решено Штраф
1 Um_nik 7 179
2 isaf27 7 343
3 BlackPuppy 7 357
4 eddy1021 6 157
5 ppc_qjd 6 176

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

Место Участник Число взломов
1 halyavin 200:-25
2 eR6 87:-58
3 jhonber 29:-1
4 Winniechen 35:-13
5 Kaban-5 19
Было сделано 697 успешных и 674 неудачных взломов.

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

Задача Участник Штраф
A arknave 0:02
B eddy1021 0:06
C bekzhan97 0:12
D teja349 0:12
E step_by_step 0:10
F lee_sin 0:24
G uwi 0:39

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

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

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

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

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

What will be the penalty, 20 or 10 ..??

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

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

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

=A=

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

Why those great bootcamps don't have public videos for participants not being able to manage to there ?

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

    then why should some people go there on their own expense,they would also wait for videos/tutorials to get public.

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

Have anyone noticed that after Codeforces Round #503 and #504, although rating recalculated in users' profiles, RATING page and Top rated page didn't change?

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

    Yeah, but the colour changed, so now the Top rated page has 9 nutellas and one red (who's in the 9th place)!

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

.

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

The internet of machine room is out of service, sadly I have to use my wifi to play codeforces....

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

Assalamu alaykum MikeMirzayanov!
When will you update Rating?

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

Assuming ACM ICPC rules, the problemset won't be sorted by increasing difficulty, right?

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

Hey, what will happen with Round 505? It starts tomorrow when hacking phase is still going on

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

halyavin is going to take part in the round! Stay determined!

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

How to solve F?

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

    My idea was doing binary search. And for checking matching, we can use Hall's theorem.Here hall's theorem converts to checking each component has more exam days than students.

    It gave TLE on 46th. So now I think the above procedure can be done with a dsu and a sort. Hopefully it should pass

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

      Nice application of Hall's theorem.

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

      Yeah DSU works

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

      I managed to get it accepted this way (binary search + application of Hall's theorem) although several attempts were required.

      Adding rank heuristic and getting rid of rand() calls in my implementation of DSU is what finally worked.

      Code: 41803434.

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

      I just binary search and matching. In the contest, I got WA on 17th because of the mistake of binary search :'( (41788874 ), just fix it and got AC. (Matching in O(n^2)) 41796159. Sorry for my bad English

      • Edit: TLE main test.
  • »
    »
    6 лет назад, # ^ |
      Проголосовать: нравится +3 Проголосовать: не нравится

    Perhaps a 2-SAT solution exists?

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

      Yes, I did 2-SAT with binary search: 41787621 (MLE Test 45).

      We have two variables Vai and Vbi for each exam, with Vai positive if we want to take exam i on day ai.

      Of course, if the binary search value we are evaluating is smaller than bi (resp. ai) then Vbi (Vai) has to be false.

      Then we just need to enforce "at most one exam a day", which I did by taking a prefix and suffix OR of the variables correp. to exams on a given day. Please ask for more details if the code / my description is unclear.

      Note that this uses 6N variables (3 for each day each exam is on).

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

        Hi! It took me quite a long time to understand the prefix/suffix OR idea. I reimplemented your solution using Tarjan algorithm for SCC, and got TLE on test 45. I generated random test of the same size, and it takes ~16 seconds. So I don't think it is possible get this solution accepted, the constant factor is just to big - the memory allocation for the graphs are the culprit I guess. Thanks for the idea though. (https://codeforces.com/contest/1027/submission/42493816)

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

          Stopped creating a new graph in each binary search check, just set the variables which are out of range to false, got down to 7 seconds. Can't think of any other reasonable change. I would really like to get it accepted :(

          https://codeforces.com/contest/1027/submission/42496525

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

            I tried to reduce your binary search iterations via coordinate compression and now we have 42497321 — MLE Test 46.

            To make testing easier (instead of local testing on random large instance), you can make mashup with only this problem, and change TL and ML to whatever you like.

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

So What's test 9 problem C?

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

    No idea, to be honest. Just 25000 testcases of size 40 with random sticks.

    I can provide you with generator and command line arguments if you need it.

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

      Nah,I'll just cry in corner,Thanks anyway for the contest and nice problems

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

      I have a feeling the time limit constraints are too strict. My java solution (equivalent of an acc C++ soln doesn't seem to pass..) Are the problems just meant to be solved in C++?

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

        Two problems with your solution (that I also faced during contest):

        First is your frequency arrays. You're recreating your freq array for every test case. If the number of test cases is 25,000 recreating that array so many times is very time consuming. You should instead reuse the frequency array and only clear an element the first time you access it during a test case.

        The second problem is your output. You're using System.out which is much slower than using a PrintWriter. But that'll still get TLE. Instead, you should append all of your output to a StringBuilder and print once after doing all test cases.

        I agree it's kind of annoying but sometimes you need to do annoying things to make things pass in Java.

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

Боже ж мой... Как решить задачу С?)

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

    Если a и b — стороны прямоугольника, то P^2/S = (2a + 2b)^2/(ab) = 4 * (a^2 + 2ab + b^2) / (ab) = 4 * (a/b + b/a + 2). Получается, нужно минимизировать a/b + b/a. Если нарисовать график a/x + x/a, то можно заметить, что минимальное значение он принимает при x = a. Поэтому нужно отсортировать все длины, и рассматривать каждые 2 подряд идущие пары длин (например, для 1 1 2 2 4 5 8 8 нужно проверить 1 1 2 2, 2 2 8 8). Таким образом выбрать лучший вариант. Если есть 4 одинаковые длины, то это и есть ответ.

    P.S. По крайней мере, это прошло претесты...

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

One of the weirdest contests I ever seen !!! Solved C and D and couldn't solve A nor B !!!

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

whats test 5 in C ?

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

    166666 testcases with lists of size 6: 3 pairs of equal lengths. I can provide you with generator and command line arguments if you need it.

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

    Minimum difference might not give optimal answer.

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

In C is it not optimal that we always choose the two sides which have minimum difference and for those differences (of length and breadth) which are equal check for them explicitly whose given ratio (p*p/s) is smaller ?

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

    not just the ratio.. you need to minimize x/y + y/x

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

      Yeah but this would be minimum when x is closest to y (obtained by differentiating) and for those whose difference b/w x and y is same we compare which of ratio (x/y+y/x) is smaller. Did i miss something ? I guess i increased conditions and computation but still could not figure out why WA. Though your code make sense. Thanks !!

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

        if you fix one of x or y.. then you can say that the other one has to be closer.. but that does not mean that the closest pair will be the answer

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

          only adjacent ones need to be checked. we need to minimize (a/b) + (b/a) where a and b are the 2 sides. define x = (a/b), then we need to minimize x + 1/x which is done when x = 1. So checking only closest elements is sufficient

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

            Actually what he said was that finding two closest (with min difference) does not give required answer.

            For eg 18/2 is 9 and 500/100 is 5, smaller than 9 despite of having difference as 400 which is greater than that of former one.

            Sorting in this case worked because for a given element if we want to check smallest possible ratio then we want just smaller one because all others will give a higher ratio (mistake i did by differentiating by keeping one variable fixed) because in this case we are talking with respect to particular element a[i].

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

      Could you explain how does one get from

      p * p / area

      to x/y y/x ???

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

    I was thinking about 1 1 2 2 15 15 20 20...

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

    f(x, y) = (2*x + 2*y)^2/(x*y) f(1, 2) = 18, f(100, 109) = 16.03

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

    this site plot functions with 2 variables, it can give you a visual vision for the function varaitions, hence you can find it's minumum.

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

Didn't solve C... I'm feeling like a fool...

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

What's test case 23 in D and test case 9 in C ? :/

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

How to solve E?

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

    An observation is that when the color of the first row and the color of the first column is determined, then the color of the whole matrix is determined, and the maximum area of the rectangle of the same color equals to the maximum number of consecutive grids of the same color in the first row multiplies the maximum number of consecutive grids of the same color in the first column. Thus you can do a dynamic programming computing for each k, how many arrays of length n such that the maximum number of consecutive grids of the same color equals to k, and then easily find out the answer.

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

      When u get the observation but don't attempt it more after seeing the modulo (fft).

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

      I have a question, can you help me? qwq If the first element of two arrays is different, how do we merge the two arrays? For example: n = 2, and k = 2(k is the maximum number of consecutive grids of the same color in array) we can get: "00" "11" but I can't understand how to generate the matrix?

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

I faced an issue in this contest ! Read about it here(https://codeforces.com/blog/entry/61298) and present your views !

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

Is F binary search on day and apply halls theorem for checking the validity in the binary search ?

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

 damn...

This submission was made 20 seconds before the end. I started about 20 minutes late into the contest and I wrote the code for G in a real hurry so I didn't even know the code was going to pass a lot of tests.

I hoped for a miracle but guess that's not happening today :(

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

What's test case 23 in D?

I was considering it as graph and finding the sum of minimum costs in cycles in different connected components, but got WA on test case 23.

Edit : It was a minor bug in implementation

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

    Your solution fails on

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

      Isn't the answer 1 in this case (the rat will come in the first room sooner or later so placing the trap on first room would work) or I'm missing something ? (My code is outputting 1 but it also got WA in test case 23)

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

      My answer is 1.

      And I think that's correct :|

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

    you need to calculate minimum of costs which are part of a cycle.. not its branch

    1->2->3->4->2.. here you have to consider 2,3,4 and not 1 bcoz 1 is not a part of the cycle

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

      I am doing the same... I am first isolating a cycle and considering the minimum cost of elemenents in the cycle...

      Also I'm taking use of the fact that there will be exactly one cycle in a connected component(considering it as undirected graph).. isn't it right?

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

        yeah but see the test case in which you got wa.. there might be something wrong in your implementation

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

    Just realised now that I can see that test case :|

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

How do you solve D? I realized the problem was much harder when it wasn't a tree.

UPD: Nvm you just dfs from two roots

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

    Find minimum Ci in every cycles and add these minimum to answer.And note that cycle can be with one node(self loop).

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

41776119 It gave WA on test 5 in C. I tried to minimize l/b + b/l. Although I later ACed it by hardcoding the functions for area and perimeter, I still couldn't figure out my bug in the first approach. Any idea what's wrong? Thanks in advance.

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

    Not completely sure, but the problem seems to be the line

    maxx = (ll/bb + bb/ll);

    maxx is an integer, and ll/bb+bb/ll is a float/double.

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

      Damn, that was the bug. Spent an hour trying to debug it. Anyways, thanks a lot :)

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

        actually i checked it on my computer and the problem is with this line: int maxx = LLONG_MAX

        xcode is smart enough to warn about wrong conversion: Implicit conversion from 'long long' to 'int' changes value from 9223372036854775807 to -1

        ideone example

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

Я уже довольно давно на CF, но так и не понял те кто 2100+ рейтинга на ed раундах влияют на рейтинг других или нет? Т.к. если я убираю галочку "показывать неофиц", они остаются.. Делая вывод я так понимаю, что они все же влияют на рейтинг, но у них он не меняется?? можно ссылку на подобную инфу, или просто объясните =)

upd: всем спасибо!)

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

    Во время рассчета рейтинга учитываются только пользователи с рейтингом менее 2100, почему отображаются оранжевые и красные — не знаю, наверно баг такой:)

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

      В таблицах div3 раундов есть похожая(мне кажется) проблема. В таблицах результатов недостоверные участники и они влияют на рейтинг других.

      В этом комментарии я описал проблему. Автор ответил что это баг, попробовал починить. Однако ничего не изменилось. Я написал об этом, но не получил ответ, и все мои комментарии об этом баге жестоко :( заминусовали(мой вклад тогда упал с +13 до -3).

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

        MikeMirzayanov, vovuh ничего не изменилось. В следующем div3 раунде(Codeforces Round 501 (Div. 3)) все повторилось. Например Wavyn занял 1 место, но в его истории контестов написано что он занял 3 место, delete4 занял 2 место но записано 8 место.

        Если я неправильно понял, то пожалуйста, скажите.

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

          Достоверность участников никак не связана с рейтингом, рейтинг получают все участники с менее 1600. Официальная таблица отображает только достоверных участников.

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

      Jostic11, здесь это не баг, все участники действительно считаются официальными, граница рассчета рейтинга от этого не зависит и остается на 2100.

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

i was getting wrong answer in problem b in java because i was using Math.ceil() function. can anyone help me why this is happening ? failed submission http://codeforces.com/contest/1027/submission/41770896 Accepted submission http://codeforces.com/contest/1027/submission/41791415

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

I was constantly getting logged out of my account during contest.Don't know what it was because of my slowed down wifi today or something else.It ruined my contest today

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

What is the complexity of memset in C++..? I read it is O(Size of Array to be initialized) but in Problem C, I used memset for an array of size 10000 in all the testcases and it passed all the pretests..How?

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

    The memset function is highly optimized by those professional engineer, it's very fast.

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

    There are some hardware acceleration inside menset(), for example, it can be done parallelly. Also you can set 8 bytes at a time if you are on a 64 bits machine

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

Спасибо всем, кто готовил этот раунд, очень понравилась идея с мультитестами для первых трех задач. awoo, правильно ли я понимаю, что эта практика будет продолжаться в будущих раундах для ускорения проверки наиболее частосдаваемых задач?

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

A solution for problem C:

  1. Since it needs to form a rectangle, we only pick those sticks which have a equal-length pair.
  2. Sort these sticks, check every adjacent stick pair to find which one has the smallest P^2/S.

This works because the smallest value must appear in the adjacent pair, here is a proof:

1.Let these two stick pairs have length a and b, minimizing P^2/S is equal to minimizing a/b + b/a.

2.Suppose b = a + d, d >= 0. a/b + b/2 = a/(a + d) + (a + d)/a, get derivative for d, it's positive in our concerned area, that means the minimum value must appear in the adjacent pair.


I didn't notice the rectangle constraint in the first glance, found it unsolvable. :(

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

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

How to solve F?

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

I wonder why my solution for problem C runs 1840ms but others solution runs 421ms???

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

    Because in every test cases you are clearing cnt array which is O(T * sizeof(cnt)).

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

    You're resetting cnt every test case even when n=4. 250000 testcases with n=4 and your solution should give tle.

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

    It is not because of memset.

    Firstly, the complexity of the other's solution is not O(T nlog(n)) but it is something like O(106log(106)), and your complexity is not O(Tn) but it is O(T 104), and here is the problem, because when T = 250000 and n = 4 for each testcase, then you will iterate, for each testcase, 104 times while you could iterate over 4 elements atmost (n = 4).

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

      I solved it in O(T*nlgn) but still the solution was hacked by the test case that you mentioned and the verdict of the hack was TLE . I can't figure out the reason as I am only doing O(nlgn) operations in each test case . My submission

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

        I have just finished testing your submission and the problem was with big I/O data. So, you just need to convert cin/cout in your code to scanf/printf.

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

          Thanks a lot! I was really unable to find my mistake.

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

            Welcome :)

            • »
              »
              »
              »
              »
              »
              »
              6 лет назад, # ^ |
                Проголосовать: нравится +3 Проголосовать: не нравится
              ios_base::sync_with_stdio(false)
              

              Will adding this line solve the problem or I have to use printf and scanf ??

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

                On my computer, scanf/printf were faster 3 times than ios_base::sync_with_stdio(false) (the last one took almost 2111 ms but the first took 766 ms almost), but yes it will solve the problem on Codeforces.

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

The time limit set in the today's contest was very stringent for python guys. I was getting a TLE for O(1) solution, whereas when I used fast I/O after the contest, my code passed all the test cases by just 1 millisecond and later on it was hacked by someone and the verdict was TLE. It would be great if you could increase the time limit by one-two second, for people coding in python. Since, everyone knows python is 5 times slower than c++. As increasing the TL by one second, won't allow any O(n) or above solution to run. So, if possible do it for both B and C.

Also, I wished to raise it as a general concern as well. Every time I code in python there is some TL issues. Why don't you guys provide a X5 multiplier for python similar to other coding sites? As it would encourage the use of python in CP. If the problems are specifically designed for c++, just tell it before the contest starts.

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

    Python gets other advantages such as many inbuilt functions big integers etc. So it's a trade off.

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

      I completely agree with you, but don't you think that there should be at least an AC in every programming language allowed, which passes the given time limit by a comfortable margin?

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

    Why would you necessarily want to encourage the use of Python in CP? Lots of contests don't allow the use of Python (ICPC, GCJ, etc.) or it's completely infeasible to solve some of the problems in Python (FHC), so I don't see why CodeForces should encourage the use of Python in any way.

    EDIT: Made a mistake, ICPC and GCJ allow Python. However, for ICPC, solutions are only provided for C++ and Java, so it is not guaranteed that one can solve a question in Python. Same is probably true for GCJ now that it is judged on their servers rather than running input on our own machines.

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

      Python is now allowed in all the contests like ICPC, GCJ and FHC. I didn't mean that I specifically want everyone to code in Python. If it seems so through my words, I am sorry. But what I meant is, if someone gets TLE on a perfect logic, then his interest goes low, even though he might be good at CP.

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

Can anyone explain why i was getting TLE in C when dealing with double and got AC when dealt with integers AC ....TLE

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

How to solve problem D ?

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

    In a circular path of the mouse, we should place trap in the room with minimum cost. This same trap will work for those rooms also from which you can enter this cycle. Summing over all such rooms( corresponding to each cycle ) will give the answer.

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

       what to do in this case ?

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

        So you have the cycle 1-2-3-1 in this. Pick the room with minimum cost in this cycle (say room x). Also you can reach to this cycle from 4. This covers all the nodes. Answer will be cost of x.

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

    Hint: When a loop is found, we can travel around the loop again to get the minimum cost.

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

Could anyone provide a hint for G? Also, I know F is about Hall's theorem, but how to implement it?

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

Hey can someone help me understand what is wrong with my solution? I am checking each adjacent numbers that are >=2 using a map and i am getting wrong answer on a list on the last test https://codeforces.com/contest/1027/submission/41804552

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

In problem C, is it mentioned somewhere that we have to minimize the length of sides as well after minimizing p^2/S. I am asking this because I submitted a solution where printing a larger side for the case when all sides are equal is giving wrong answer while if we take the smallest side Accepted is given.

Links to submissions:

Wrong Submission

Accepted Submission

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

    If you look test 3 of your WA submission, you will see that you are printing numbers that doesn't belong to the input array (the judge says "wrong answer Given lengths aren't present in the input list for list 5").

    You can check that minimizing is not necessary in this submission. I used your code but I didn't update the answer if I already found one, and it got AC.

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

      I too initially thought that the sides might not be present but when I checked (Look at this submission) I found the sides are in fact present in the list.

      PS: My previous submission said that the give side is not present in list 5. So I tried to print yes when whenever I found that side to check it.

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

        Yeah, that's weird, but minimizing the lengths is not really necessary (I updated my previous comment with a submission link). I really don't know what's going on :P

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

          Yeah that's the point. It is clearly mentioned in the question that you cant print any of the possible values. But they are accepting only the least one.

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

            The submission I posted in my comment prints 5314 5314 5314 5314 for that input list, yours prints 2 2 2 2, and the judge says both of them are ok, so not only the smallest side is considered as correct. Maybe there is some kind of bug for some values. I'm sorry that I can't help you with that!

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

When does system testing start?

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

    it hasn't started even now.. Will the submissions won't be check at system tests(pretest + hacks) this time?

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

When will the rating be updated ?

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

When will the ratings change?

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

Can someone please provide the 5th list of test case 3 in C. I am unable to spot the error in my code.

Error : wrong answer Given lengths aren't present in the input list for list 5

Code : My Solution

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

    You don't need the break in your loop. You don't finish reading the current list before proceeding to the next one.

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

Why system test doesn't start right after open hacking phase? Contestants always need to waiting long time for system test and it's really boring and annoying...

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

    you can calculate by yourself,according to the standings and your points

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

      before system test, standings are not real standing. I know how to calculate rating change, but that's not the point. we can know real contest result only after the system test. I want to know the real result, not the expected rating change.

      and I really can't understand the reason why system test couldn't start automatically. I want to know the reason why we must need to waiting long time for starting system test.

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

What happened with the system test? The next contest will begin in 8 hours but the system test of this contest disappears.

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

When will the system test start?

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

The system tests are started!

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

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

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

When will the system test start? it seem we are going to wait forever!

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

when the ratings begin change?

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

How long will take it to calcuate the rating changes?

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

Why the rating changing still can't be seen??

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

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

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

I have solved C bt cant come up with a solution for B.. plz help!!

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

Rating has improved.I am happy.

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

The contest has helped me a lot !!!! thank you very much :)))

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

In Problem 1027F Session in BSU, Some people AC this problem by using Hungary Algorithm I can make the data to Hack Hungary Algorithm's solution (eg:41789514) How can I give my data to Codeforces? I only don't hope these people are mislead by Hungary Algorithm Sorry.I am not good in English,Can you get my meaning?

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

I am getting RTE on test case 45 in D Anyone help Submission link : https://codeforces.com/contest/1027/submission/48291955 Using normal dfs to detect cycles