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

Привет, Codeforces!

В 15.02.2021 17:35 (Московское время) состоится Educational Codeforces Round 104 (рейтинговый для Див. 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!

Как мы и обещали в прошлый раз, мы вернулись с новой возможностью получить стипендию!

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

В сотрудничестве с Coherra мы предлагаем полную стипендию для обучения в магистратуре "Front End Development" в Harbour.Space, во время которого вы будете проходить стажировку на позиции front end-разработчика в Coherra!

О стипендии:

Работа в самых интересных технологических городах Европы

Размер стипендии до 22900 евро для обучения в Harbour.Space University

Компенсация за стажировку в Coherra

Возможность работать в Coherra полный рабочий день после окончания учебы

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

  • Место full stack разработчика в OneRagtime занял Alejandro Martinez из Мексики
  • Место innovation designer в Hansgrohe занял Giorgi Zhuzhiashvili из Грузии

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

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

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

Harbour.Space University

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

Место Участник Задач решено Штраф
1 Muffinhead 7 211
2 noimi 7 271
3 LayCurse 7 279
4 satashun 7 333
5 nhho 7 366

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

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

Задача Участник Штраф
A BOOBA 0:01
B noimi 0:04
C MurasakiShion 0:07
D peti1234 0:06
E Bhaiya_ko_nahi_batana 0:12
F uwi 0:51
G renascencepjw0510 0:27

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

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

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

I wish this contest took place today. For single guys like me this could have been the perfect valentine :'(

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

What is the reason behind Educational round not having any testers?

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

I hope that the conditions will also be short and clear as in the last round :)

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

I will do a stream after the contest, on https://twitch.tv/AnandOza

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

Can we expect short statements? It would be very pleasant to see short statements on the problems :)

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

Just 1 day earlier and this contest might be my savior in the day that wasn't born for a single like me

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

Yesterday was 3 years since my first contest, that was a Valentine contest. As luck would have it, problem A was the most difficult in the history of the Div2 rounds, its difficulty was 1400 !!!

Meme of that round:

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

All I wanted from Mike:

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

...

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

Is it not true that the round is Rated?

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

H

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

Hello guys finally i am back after a pause of 20 days because of my faulty laptop but hey... i have practicing on paper a lot ....so i hope today i become specialist . As always good luck to all. Keep Coding!!

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

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

Can somebody recommend me some basic problemset on DP and Graphs. I am able to solve standard problems but I struggle a lot on codeforces. Please recommend some good resources for the same too.

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

Valentine’s Day is the programmer’s holiday.

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

Really Excited for this contest, in last 2 contests I dropped down my from my Specialist spot. Hope I will regain it in this Contest. Good luck to everyone <3

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

those cyans who will be blue today will regret tomorrows div3

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

Is this TypeRacerForces?

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

I didn't like a single one of the problems, and probably no one did. Is there a joke I didn't get? Why did you do this?

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

I think I burned my every brain cell solving C. Atleast I succeeded.

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

How come (sqrt(2 * n + 1) — 1) / 2 isn't the solution in D?

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

I can't be the only one who found D easier than B?

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

    And easier than C as well ...

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

    I just searched it on Wolfram Alpha

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

    Yeah for me D was easier than B and far easier than C. How did you guys solved C?

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

      Parity of sum i+j. If the number of teams is even, game of teams $$$2k$$$ and $$$2k+1$$$ $$$(k=0...\frac{n}{2})$$$ is a tie

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

        My solution is very different and I am yet to prove why it is correct Basically we can find a formula $$$n(3n - 3 - 2s) = \sum{t_i}$$$ where $$$s$$$ is score of each team and $$$t_i$$$ is number of ties played by team $$$i$$$. Here comes my unproved assumption that each team will play same number of ties. Now to minimise total ties maximize score and then I just greedly assigned wins, loses and ties and I don't know why this is correct

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

          By giving explicit constructions, we can show that it is possible to have $$$0$$$ ties if $$$n$$$ is odd, and $$$n/2$$$ ties if $$$n$$$ is even. So, to prove correctness, we only need to show that when $$$n$$$ is even, then $$$n/2$$$ ties is the best number of ties possible.

          Claim: If $$$n$$$ is even, then the minimum number of ties must be at least $$$n/2$$$.

          Proof: If there are exactly $$$T$$$ ties among all $$$\binom{n}{2}$$$ matches, then the total score of all teams must be $$$3\left(\binom{n}{2} - T\right) + 2T = \frac{3n(n-1)}{2} - T$$$. Since each of the $$$n$$$ teams gets the same score, this number must be divisble by $$$n$$$.

          We now use the assumption that $$$n$$$ is even. We can assume that $$$n = 2k$$$ for some positive integer $$$k$$$, and hence, $$$\frac{3n(n-1)}{2} - T = \frac{6k(2k-1)}{2} - T = 6k^2 - 3k - T$$$. This must be divisible by $$$n = 2k$$$. It is easy to see that this is true when $$$T = k = n/2$$$, and there is no smaller possible value for $$$T$$$. $$$\square$$$

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

            I believe that this solution gives another nice proof of why the number of ties is optimal (since it argues in terms of in-degrees and out-degrees of a vertex which need to be equal).

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

            From this, we can also show that for any optimal configuration with even $$$n$$$, each team must have exactly one tie.

            Indeed, from the proof above, we know that the total score of all $$$n$$$ teams is $$$6k^2 - 3k - k = 6k^2 - 4k$$$, so the total score obtained by each team is $$$\frac{6k^2 - 4k}{2k} = 3k - 2$$$, which is not a multiple of $$$3$$$. On the other hand, if a team has no ties, then their total score is a multiple of $$$3$$$. So, it is impossible to have a team with no ties. Each team must have at least $$$1$$$ tie.

            Together with the fact that there are $$$n/2$$$ ties in total, it is easy to see that each team must have exactly $$$1$$$ tie.

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

      Greedy)))

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

    I misread the statement of problem B :( And stuck on it for an hour...

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

can anyone explain how to approach question d..like i am failing in the tc.

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

    From the two formulas it follows that $$$c=b+1.$$$ Moreover, difference between $$$c$$$ and $$$c-1$$$ must be a square

  • »
    »
    5 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +2 Проголосовать: не нравится
    • `It involves a bit of mathematics. So you have 2 equations

    1) a^2 + b^2 = c^2

    2) c = a^2 - b

    • From equation 2, find the value of a^2, which is c + b and then substitute it in equation 1. From there, you will a relation of the form c * (c-1) = b * (b+1). On careful observation, you will see that this can be true only when b = c-1. So, the problem reduces to counting the number of pythogorean triplets having the length of the hypotenuse and the longest leg differing by 1.

    • As it turns out, such a triplet has the form (2n + 1, 2n^2 + 2n, 2n^2 + 2n +1). Here is the hypotenuse is of the form 2n^2 + 2n + 1 and hence you can easily loop until you reach the limit.

    • Link to my submission: https://mirror.codeforces.com/contest/1487/submission/107441210

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

    Pythagorus theorem -> a*a+b*b=c*c , a<=b<=c

    and eqn in question -> c=a*a-b

    solving both equation we will get c = b+1

    so let b = m then c = m+1 and a = sqrt(2*m+1)

    since c<=n

    so m+1<=n => m<=n-1 => 2*m<=2*n-2 => 2*m+1<=2*n-1

    sqrt(2*m+1) <= sqrt(2*n-1)

    so our ans is number of odds(since 2*m+1 is of odd form) less than or equal to sqrt(2*n-1)

    but we have to subract one from our ans since sqrt(2*m+1) cannot be 1(if it is 1 then m = 0, which is not possible).

    Hope it helps.

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

    c=a2-b

    a2=c+b

    3*3=9=4+5

    5*5=25=11+12

    7*7=49=24+25

    9*9=81=41+40

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

Anyone have a clue what test 18 of E is?

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

I think that there is a bug with the penalty for wrong submissions for this round. I made one wrong submission for problem B(and got no time penalty) and three wrong submissions for problem C (and got only two time penalty).

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

Is E just doing DP courses by courses and for storing DP values of previous course in segment tree to get DP values in current course i.e. for DP[i] in current course we will get $$$m$$$ segments in previous course to consider value?

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

Wrong answer on test 40 on E :( This is annoying

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

The risk I took while submitting C was calculated but I forgot that I'm bad at math (-_-)

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

[pE] What's the point of having 4 things.

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

Maybe the gap between E and the last two problems are a little bit too large(which according to the statistics are solved by 973,14 and 42 participants respectively)

anyway,good problems and strong pretests!

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

ParityForces

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

This contest was not at all educational.

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

The formula of D is $$$ b(b+1)=c(c-1) $$$ i.e. $$$ b=c-1. $$$ Difference of squares $$$ n^2-(n-1)^2 = 2n-1. $$$ For all $$$i=3...10^5$$$ write down all $$$n$$$ such that $$$ n^2-(n-1)^2 = i^2 $$$ (or $$$i^2 = 2n-1$$$ or $$$n=\frac{i^2+1}{2} $$$) and use binary search to count the answer

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

Any ideas why this gives wrong answer in test 24 for E:107463591

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

Can someone explain the approach for problem E? I think we have to start finding the minimum value from each of the n3 values to n4. Now we will move to n2 and then find the minimum from n2 to n3 for each n2 and so on.... Am I correct? If the logic is same then how all of you optimized?

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

    I wasn't able to code completely but i think following would have worked :

    Consider a,b,c,d as arrays consisting of cost of first course, a second course, a drink, and a dessert.

    Now in array b , for each index we can add minimum cost in array a.

    Similarly for each index in c we can add minimum cost in array d .

    In both above we need to consider only those pairs which are not connected . It can be done with multiset .

    Now for each index in b find minimum cost in c and take the minimum.

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

      Yeah I am saying the same thing. But isn't finding minimum will be O(n^2)? How are you optimizing it?

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

        Suppose for each value in $$$b$$$ we need to find minimum cost in array $$$a$$$. You can create multiset consisting of pair $$${a[i],i}$$$ . Now you can create adjacency list for array $$$b$$$ such that for each $$$b[i]$$$ it contains all $$$i$$$ in $$$a$$$ which it cannot be paired with.

        While traversing $$$b$$$ , at particular $$$i$$$, remove all those pairs from multiset and then take the minimum value . finally add again all those values back.

        Similarly for all other parts.

        Complexity would be $$$O(max(n,m)log(max(n,m)))$$$ where $$$m$$$ is all the pairs which are incompatible .

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

    You can use multiset to get the minimum value. While looking at the i'th element delete the values of the food which doesn't go with i'th element. Now get the minimum value in multiset. At last of i'th step add those deleted values back into multiset.

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

the contest is done. Can I legally upload my solutions to github?

will there be information for the solutions of the problems(unhappy to say I need only for B and C) ?

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

Thanks for the contest, even though I couldn't perform well, I got to learn a bunch of things!

Kudos to the authors

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

I don't know why my D solution was giving TLE using C++14 and then got AC after I submitted with C++17. Can anyone please help me out?

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

Getting input on E was harder then solving real problem

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

Why always easier G than F in edu rounds?

upd: sorry, it seems just last two round has easier G, but why?

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

Solved A in 2 minutes and given rest 118 min to the B, finding patterns in the smaller input. But, was not able to crack it. WTH!! happened to my brain. Ahh... this feeling can't be expressed in words.

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

Approach for D :
c = a*a-b & c = a*a+b*b
c*c = (a*a-b) * (a*a-b)
a*a + b*b = a^4 + b*b-2*a*a*b
On simplifying,
a*a=2*b+1
Now you can do a binary search for this.

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

Which formular we need to google or recite to solve D?

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

Who else got memory limit exceeded in E?

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

Due to a typo, I somehow found that min(v.begin(), v.end()) compiles, but will probably give wrong answer. It took me so long to find the typo. Can someone explain why it compiles and the result of it?

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

E was so painful to solve!

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

Something is special with the number 1337. I see it everywhere :)

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

Me whole time, during the contest.

Kudos to 6th consecutive negative delta

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

I solved F using a simple Dijkstra. I have no proof why the number of states is small enough.

Can you hack it or prove its correctness?

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

    The entire state space your Dijkstra routine is exploring is of size $$$O((\log n)^2)$$$. Consider the number $$$x = 9*\mathrm{curr}$$$, written with no leading zero. Then your two operations on $$$\mathrm{curr}$$$, viewed as operations on $$$x$$$, are:

    1. invert every digit in $$$x$$$, or
    2. subtract 1 from the leading digit of $$$x$$$, then add 1 to $$$x$$$.

    Then it should be easy to see that from a given value of $$$x$$$, there are at most $$$2 \times 10$$$ values of $$$x$$$ that can be reached with the same number of digits, and at most $$$2$$$ values of $$$x$$$ with one digit less. These $$$2$$$ values will (up to inversion of digits) differ by either $$$9$$$ or $$$10$$$. Extending this idea, up to inversion of digits, the ways to remove the first $$$k$$$ leading digits of $$$x$$$ fit within a range of size $$$10k$$$. This leads to there being at most $$$20k+1$$$ of them, which leads to the $$$O((\log n)^2)$$$ bound I claimed.

    EDIT: I made a dumb oversight initially, but the idea of this comment should still more or less work. I expect the constant factor is in practice better than what my revised argument suggests, by about a factor of 5.

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

i was counting the pythagorus tripets where c=b+1 by the loop of pythagoras generator and it is giving TLE error any easier method ??

void pythagoreanTriplets(int limit) 
{ 
  
    // triplet: a^2 + b^2 = c^2 
    int a, b, c = 0; 
  
    // loop from 2 to max_limitit 
    int m = 2; 
  
    // Limiting c would limit 
    // all a, b and c 
    while (c < limit) { 
  
        // now loop on j from 1 to i-1 
        for (int n = 1; n < m; ++n) { 
  
            // Evaluate and print triplets using 
            // the relation between a, b and c 
            a = m * m - n * n; 
            b = 2 * m * n; 
            c = m * m + n * n; 
  
            if (c > limit) 
                break; 
  
            //printf("%d %d %d\n", a, b, c); 
            int d=max(a,b);
            if(c==d+1)
            ans++;
        } 
        m++; 
    } 
} 
  • »
    »
    5 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    We have 2 equations. 1) c^2 = a^2 + b^2 2) c = a^2 — b

    If we substitute the value of c from 2nd eqn. to first eqn. we get,

    a^4 + b^2 — 2*a^2*b = a^2 + b^2 ==> a^4 — a^2 = 2*a^2*b (By rearranging terms) ==> b = (a^2-1)/2 ==> c = (a^2+1)/2 (By substituting the value of b into eqn.2)

    We can see that c>=b>=a. For c to be less than or equal to n, a<=sqrt(2*n-1). Also for b and c to be integers a should be an odd number != 1.

    So the answer is number of odd numbers from 3 to sqrt(2*n-1)

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

    Yes...use the same function to precompute the all the pairs till 10^9 and store a,b,c in different arrays let's say A,B,C..now for each n..check how many elements in C are <= n as because C will be holding the max element of each triplet of a,b,c. This is not the best method to solve this question but yes this approach works for given constraints.

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

Why does DFS by complement fail on E :(

submission

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

Why does DFS by complement fail on E :(

submission

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

PatternForces

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

Deleted

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

how to solve C

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

    The main idea is we can put the teams on a circle. Then if $$$n$$$ is odd team $$$i$$$ won from teams $$$i+1,i+2,...i+\frac{n-1}{2}$$$(with cylic shift). And if $$$n$$$ is even team $$$i$$$ won from teams $$$i+1,i+2,...i+\frac{n-2}{2}$$$ and tie with team $$$i+\frac{n}{2}$$$.

    code

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

    Solution. You can fill adjacency matrix with checkerboard pattern (if $$$n$$$ is odd), mirrored by main diagonal. Then every line and every row has the same sum. In case $$$n$$$ is even -- every team must play one game in a tie. Simplest way to put 'tie values' on adjacency matrix such that any two 'tie values' are on the same row/column -- put them on second diagonal by checking the sum of indexes $$$row + col == n$$$. Bus you also need to mirror values by second diagonal (only in case of $$$n$$$ is even).

    Example or filled matrix (according to described pattern)
    • »
      »
      »
      5 лет назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      thanks for your efforts

      but after giving 2.5hours+ still i am not comfortable that how this is working ..... i know this is a valid pattern but unable to answers whether i can think this on my own in or after contest..

      at the end ..... waiting for editorial.......

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

    You can solve C by induction.

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

why this solution is not getting TLE? Link: https://mirror.codeforces.com/contest/1487/submission/107421373

Because the number of time for loop running = 22360*10000 = 223600000 ~ 2*10^8

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

Please, Can someone help me understand why below output(sequence) is wrong for Que C : Minimum Ties

when input is n = 4

my output(sequence): 1 -1 0 1 -1 0

I'm getting WA on testcase 2, my submission

Thank You!

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

Why this solution is not getting TLE?

Solution Link:https://mirror.codeforces.com/contest/1487/submission/107421373

Because the total number of times for loop is running = 22360*10000 ~ 2*10^8

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

I solved

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

How do you solve E?

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

I know math is very important in competitive programming. But isn't this too much?

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

Please, Can someone help me understand why below output(sequence) is wrong for Que C : Minimum Ties

when input is n = 4

my output(sequence): 0 1 -1 0 1 1

I'm getting WA on testcase 2:https://mirror.codeforces.com/contest/1487/submission/107460842

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

the game may result in a tie, then both teams get 1 point.

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

Joke problems in an edu — round . first 4 problems are joke.

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

In C, I was able to find the solution pretty quickly but for 1.5hrs could not find a way to implement the ordering. Anybody faced the same issue, and then i matched i with i + n/2 (for tie ) and brute forced rest of the pairs and it passed (maybe it will fail later) ... The ordering of win and loss for any pair

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

    I mean how to decide which pair will be loss , win or tie

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

      Here's what I thought while solving problem C:

      Consider each team as a vertex in a complete graph. Then you need to direct edges (outwards for a win, inwards for a loss) such that the in-degree and the out-degree are the same for any vertex $$$v$$$, and we need to maximize the number of directed edges. The maximum in-degree or outdegree can be at most $$$\lfloor\frac{n-1}{2}\rfloor$$$ (since there can be at most $$$n - 1$$$ edges incident on any vertex). A construction for this is pretty simple too: For any team $$$i$$$, let it win against teams $$$i+1, i+2, \ldots, i + \lfloor\frac{n-1}{2}\rfloor$$$, where indices are taken modulo $$$n$$$. The construction guarantees that you assign one pair of teams a win/loss at most once, and since there are incoming edges from $$$i-1, i-2, \ldots, i - \lfloor\frac{n-1}{2}\rfloor$$$ (indices taken mod $$$n$$$), the constraints are satisfied as well.

      To implement it, you can simply create a matrix $$$a$$$ where $$$a_{ij}$$$ is $$$1$$$ if there is an edge from $$$i$$$ to $$$j$$$, $$$0$$$ if it is undirected, and $$$-1$$$ if there is an edge from $$$j$$$ to $$$i$$$, and print in the order specified in the problem statement.

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

        nice way to think

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

        Then you need to direct edges (outwards for a win, inwards for a loss) such that the in-degree and the out-degree are the same for any vertex

        Couldn't you have a case, in theory, where one player has 3 draws, and another one has 1 win and 2 losses, with them having the same number of points?

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

          Let $$$T$$$ be the number of tied matches. Then in a state with everyone having the same score $$$S$$$,

          $$$(SumOfScores) = N * S = 2 * T + 3 * (N * (N — 1) / 2 — T) = 3 * N * (N — 1) / 2 — T$$$

          Middle equality is just summing up scores for each matches (2 for each tied matches, 3 for non-tied ones)

          Odd $N$ case is very obvious so I'll skip.

          If $$$N$$$ is even, after dividing both sides by $$$N/2$$$, we get

          $$$2∗S=3∗(N−1)−T/(N/2) \leftrightarrow T/(N/2)=2∗S−3∗(N−1)$$$

          This implies $T$ is divisible by $$$N/2$$$. Since the right hand side is odd, we can't have $$$T = 0$$$, so the smallest candidate of $$$T$$$ is $$$N/2$$$.

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

        As arman.t mentioned, it's not immediately clear to me why each team needs to have the same number of wins and loses in any optimal configuration. In fact, this isn't true if we modify the number of points awarded for wins/ties/loses. For example, if winners get 2 points instead of 3 points (and everything else is the same), one optimal configuration of 4 teams with 3 total ties is as follows:

        	A	B	C	D	Total	Wins	Ties	Loses
        A	-	1	1	1	3	0	3	0
        B	1	-	2	0	3	1	1	1
        C	1	0	-	2	3	1	1	1
        D	1	2	0	-	3	1	1	1
        

        Edit: On second reading, maybe I misinterpret your comment. Are you saying that a team must have the same number of wins and loses although the number of wins of distinct teams can be different?

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

          Nice catch, I probably should have mentioned why the number of ties is minimized there. Note that if $$$x$$$ is the number of ties, the total number of points is $$$3n(n - 1)/2 - x$$$, and this needs to be divisible by $$$n$$$. If $$$n$$$ is odd, we're done by the construction since there $$$x=0$$$, and otherwise, the first expression is $$$n/2$$$ modulo $$$n$$$, so $$$x$$$ needs to be at least $$$n/2$$$, which the construction achieves. As for your observation, replacing $$$3$$$ with any odd number works, but might not work when we replace it by an even number.

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

    Simple way of ordering for odd value do this way.

    -LWLW

    W-LWL

    LW-LW

    WLW-L

    LWLW-

    For even do this way.

    -DLWLW

    D-WLWL

    WL-DLW

    LWD-WL

    WLWL-D

    LWLWD-

    alternate LWs only no complex logic as matrix is symmetric around the diagonal.

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

Educational round is too harsh.....I solved A and D but still getting a negative delta in pupil.....If it was a point based div2 I could surely have got some positive delta.....Though i am very upset with my low performance of not even being able to solve B and C today...

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

    This round was pure garbage (and I am speaking regardless of my poor performance). First four problems were all of same level. E and onward are of decent quality, but most participants didn't make it 'til that point, because of B/C fails.

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

      How they would do E if they can't do B/C? There is some examples of opposite, but there is few of them

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

        I never stated they would solve them, it's just that the first four problems provided no value whatsoever. When I can't solve a nice D2D, I spend a few hours analyzing it, but I don't regret missing today's B at all.

        E. g. I got stuck on B for an hour or so, then solved C and D in no time (messed up the +/- thing in D, but still solved 80% of the problem), does that mean that B was super hard or that I'm stupid, no? There were just too many simple tricky problems in today's round, that's all.

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

Totally speedforces. You should have excluded one of the problems from A-D, because 4 div. 3 problems on educational contest is very unacceptable There are pupils and even newbies getting negative delta for solving 4 problems, This does not happen even in div. 3 rounds.

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

    That's not true no pupil or newbie is getting negative for solving all 4. (even with absurd amount of penalty).

    agreed with the argument that problems were easier than your typical educational round but it's always like this.. some days the problems are balanced, some days they are tough and some days they happen to be lenient.

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

Can someone explain the logic of problem F? Is it digit dp? If yes then how you used it?

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

Here is my 1 line code of problem-D ..xD

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

code Problem C

Can someone please explain why my code written in C11 got a TLE? T_T

I wonder if it got trapped in an infinite loop or the code is just too slow.

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

Thank you so much for the Hardwork of making this Contest.Really enjoyed and learned new things.

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

Is this contest unrated?

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

When is editorial coming??

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

A good contest for me. Finally solving A & B both in educational round. Feeling good

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

In problem C. For n = 4 according to my approach the output is 1 -1 -1 1 0 0 and the compiler output is 1 0 -1 1 0 1. My output was shown wrong because the score of 1 and 2 are not same. But I didn't see anything difference between (1 -1 -1 1 0 0 and 1 0 -1 1 0 1). Can anyone explain it please?

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

Can someone explain on how to solve problem E ?

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

    Sorry for my poor English.I will try my best to explain my idea. First,divide the original into three parts:the first with the second,the second with the third,the third with the fourth.Then let's solve the first part:the first kind food with the second.What we want to know is for every food in the second list,which food can be selected with it and cheapest.To do that,we can form a graph and use a map to store all the price of the first kind.Then just iterate every second food,and delete the food that cannot be selected with it in map.Finally,we can easily get which one is the cheapst or clarify there is no food can be selected with it.After this,add the elements deleted before and do again for the next second food.
    To calculate the real answer,we can add the selected price with the price for the second food.Then do this for the second food and the third.Finally,the price of the fourth food would be the answer.
    Here is my solution link:107496598

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

    Sorry for my poor English, but I want to give an another idea for this problem.

    So if we want to know the best choice of group $$$1$$$, we must know that for each element in group $$$1$$$ we can choose which element in group $$$2$$$ to minimize the cost.For group $$$2$$$,we should know the choice in group $$$3$$$, for group $$$3$$$,we should know the choice in group $$$4$$$.

    Now the problem is how to make the best choice for each group. For one element, we can think that the elements which can't go well with it make some block point in number axis. The block point spilt the whole number axis into some intervals. So we can use some data structure to query the mininum for each intervals. I used Sparse Table to solve it :https://mirror.codeforces.com/contest/1487/submission/107467664

    This solution works in the time of $$$O(n \log n)$$$, if you choose the segment tree,this solution would work in the same time.

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

COPS IIT-BHU, has prepared a set of video editorials for the problems A to E of this contest.
Do check them out by clicking at This.
Hope you like the explanation

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

![ ](150927496-2854209298185767-1672263672911909316-n)

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

When will the ratings be updated? Its almost 5 hrs the system testing has been done.

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

Does Educational rounds have editorials?

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

When will the editorials be published?

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

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

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

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