Блог пользователя vovuh

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

Прошу прощения за долгие перерывы между раундами, но времени на подготовку задач мне катастрофически не хватает. Итак...

<copy-pasted-part>

Привет! В 16.11.2018 17:35 (Московское время) начнётся Codeforces Round 521 (Div. 3) — очередной Codeforces раунд для третьего дивизиона. В этом раунде будет 6 или 7 задач, которые подобраны по сложности так, чтобы составить интересное соревнование для участников с рейтингами до 1600. Наверное, участникам из первого дивизиона они будут совсем не интересны, а для 1600-1899 покажутся простыми. Однако все желающие, чей рейтинг 1600 и выше могут зарегистрироваться на раунд вне конкурса.

Раунд пройдет по правилам образовательных раундов. Таким образом, во время раунда задачи будут тестироваться на предварительных тестах, а после раунда будет 12-ти часовая фаза открытых взломов. Я постарался сделать приличные тесты — так же как и вы буду расстроен, если у многих попадают решения после окончания контеста.

Вам будет предложено 6 или 7 задач и 2 часа на их решение.

Штраф за неверную попытку в этом раунде (и последующих Div. 3 раундах) будет равняться 10 минутам.

Напоминаем, что в таблицу официальных результатов попадут только достоверные участники третьего дивизиона. Как написано по ссылке — это вынужденная мера для борьбы с неспортивным поведением. Для квалификации в качестве достоверного участника третьего дивизиона надо:

  • принять участие не менее чем в двух рейтинговых раундах (и решить в каждом из них хотя бы одну задачу),
  • не иметь в рейтинге точку 1900 или выше.

Независимо от того являетесь вы достоверными участниками третьего дивизиона или нет, если ваш рейтинг менее 1600, то раунд для вас будет рейтинговым.

Спасибо MikeMirzayanov за платформы, помощь с идеями для задач и координацию моей работы. Спасибо моим очень хорошим друзьям Михаилу awoo Пикляеву, Максиму Neon Мещерякову и Ивану BledDest Андросову за помощь в подготовке и тестирование раунда.

Удачи!

Также хочу сказать, что участники, намеренно отправляющие неверные решения и взламывающие их после окончания соревнования (пример), не будут показаны в таблице лидеров по взломам.

</copy-pasted-part>

UPD1:

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

Rank Competitor Problems Solved Penalty
1 diolG 7 173
2 lyzqs 7 228
3 pvviet001 7 241
3 LVL 7 241
5 lukameladze1 7 250

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

Rank Competitor Hack Count
1 awoo 153:-6
2 ______-__________-______ 186:-85
3 knowbody 128:-6
4 Laggay 113:-6
5 MarcosK 66:-6

Всего было сделано 1359 успешных взломов и 755 неудачных взломов!

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

Problem Competitor Penalty
A Laggay 0:01
B Laggay 0:03
C ilya_kuzmin 0:05
D Laggay 0:12
E ilya_kuzmin 0:12
F1 Greninja. 0:29
F2 Radko 0:32

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

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

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

What happen for Div. 3 contests if we haven't vovuh ?

Thanks vovuh and also thanks creator of copy-paste (Larry Tesler) :))

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

earlier i used to think that i could solve 4-5 problems in div 3 rounds as it would be easy with div3 tag , but now i knew one thing "dhoka hai ye , ek trah ka jaal, shajis hai hamein nicha dikhane ki, haha div3 tag XXXDDDD", don't take it offensively it's just a joke, i love codeforces.

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

    What a nasty comment...

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

    haha, same, man

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

      Translation?

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

        Meh, languages used are part of the joke. You'll have to believe me that it's funny and highly relatable)

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

        So i opened the refrigerator, took a tomato, a cucumber,a greenery, wanted to make salad. It is obvious the salad should be made with mayonnaise (else who who would eat it?). I cut all and realized I forgot the mayonnaise. i opened the refrigerator again, took the mayonaise and suddenly realized that there is some lard in front of me. I have never eat the lard, but i suddenly i wanted it. While I filled the salad with the mayonnaise , cut the lard, ate it and suddenly all (*something in Ukrainian)

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

      haha classic

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

Pardon me this is my first rated(hopefully) Div 3 contest. Why is this rule there?

I also would like to say that participants who will submit wrong solutions on purpose and hack them afterwards (example) will not be shown in the hacking leaders table.

They will be considered in leaderboard table though?

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

    If they solve problems fairly then yes, they're will be shown in the leaderboard. This rule is there just to exclude the people who want to be top-5 by unfair hacks.

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

      what's the benefit of hacking someone's submission ? does it increases rating or points?

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

How to get reminder for this type of contest?

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

I hope this div3 A will not be harder than div2 A as always

edit:finally it's not

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

today I'll become blue. screen it

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

After Hacknig xD
photo-2018-11-16-19-39-42

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

Thanks, vovuh !!

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

Can someone please tell me why my submission for F is getting TLE on test 41 ? Used deque and dp.

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

I can't believe I wasted that time on C that feels incredibly stupid XD

edit: and it's WA XD

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

Is E binary search?

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

What is the solution for problem C ?

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

    Start from left of the array and if there is a zero in between two ones, remove the right one. Let this be ansA, do the same for the reverse array and let the answer of that be ansB. Final answer is min(ansA, ansB).

    Sorry this is for B

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

      This is the solution to problem B Not C

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

        Sorry,

        For C: Let sum of whole array be S, then in a vector store pair of <value, index> sort this in descending fashion,

        if you are removing first element of this vector, your remaining sum is S — v[0].value. remainingSum — v[1].value should equal to v[1].value.

        else your remaining sum is S — v[i].value. remainingSum — v[0].value should equal to v[0].value.

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

          Can you please Illustrate more ?

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

            essentially there are a couple ways to create a good array, both can occur though.

            type1: removing the largest value, hence the second largest value will have to be the sum of the remaining digits, excluding the originally biggest number (and the second largest of course).

            type2: removing a value (that is not the largest), to make the sum of all the other values equal to the largest.

            you can check for both types, which is what i did.

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

      For B, I think ansA will always be equal to ansB, so there's no point in calculating both of them. If I'm wrong, can someone please suggest a test case where ansA  ≠  ansB?

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

    Observation: We are checking if removing an element from the array can make the max element equal to the sum of other remaining elements. And in case we are removing the max element, we are just checking if we can make the second max element equal to the sum of other remaining elements. (Since there is no element with -ve value) So, we just have to find out the max and semi-max element and then iterate the array removing each element at a time and checking the above criteria.

    for example, a= [5,2,1,3] Max= 5, Semi Max= 3 Removing 5(Max), a=[_,2,1,3] makes Semi Max, 3= 2+1 Removing 1, a=[5,2,_,3] makes Max, 5= 2+3 These two are only bad indices in this example.

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

How to solve the hard version of problem F ?

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

    dp[number added][last added]

    Naive transitions work in O(n) for a total of O(n^3). If we use sliding window for each layer, we can transition each layer in O(n), for a total of O(n^2).

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

Did anyone manage to AC E with dp in O(nlog(109)log(n)), something like this?

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

    For E: Store the frequency of each topic in array and sort that array. Then let say we fix the no of topics in first contest be i, then binary search on this array to find if there exists a topic with frequency greater than i, if yes then take the leftmost topic and set it as new index (initially index is 0) and then check for 2 * i and repeat the process. If not found, just break at that index. Repeat the process for new i. Code: http://codeforces.com/contest/1077/submission/45834476

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

Relief :)

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

How to approach D? what i did, first i count the frequency of every number and then i put them on a pair, but then i could not find any way that how to go further!! i could come this much :(

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

    I think recursive find() function that continuously divides possible region for k in half might solve the problem in O(nlgn), but I ran out of the time...

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

    It's easy to find an array that can by cut out x times. So just do a binary search for the biggest valid x.

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

Is it intended in F2 that using segtree gives TLE but other data structure like sparse table gives AC?

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

Why on problem F the condition if((k*2-1)*x<n) cout<<-1; isn't enough to detect if it's impossible to solve?

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

Отличный раунд получился, спасибо vovuh!

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

C Wrong answer on test 3, but I got right answer local.... Why?

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

    maybe because you need to write bool exist=false;

    if you don't it will take arbitary value

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

Mike bhaiya meri rating kyu nahi badh rhi? ye codeforces hi bekaar hai

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

Plz someone explain me, why 45840553 is TL 16 and 45840575 is RE 1 ?

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

    Your cmp function does not define a "strict weak ordering", which std::sort requires. The short version of the explanation is that your predicate should behave like < and not like <=.

    Failing to meet this requirement causes undefined behavior, which basically means that the verdict may vary arbitrarily.

    P.S: there might be other problems with the source, this is just one I have noticed.

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

What is the hack for C? A lot of C's solutions are getting hacked.

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

    Answer:

    2
    2 3
    

    The reasons for WA are various as for all of the following outputs I found a solution that produces that output:

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

It seems that I was the only one who misunderstood the statement for problem B. Can anyone tell what is it really asking for ??

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

    me too bro :(

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

    The question asks for the minimum lights you have to turn off for all peoples "sleep well".

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

      If only I had known that before. I thought they were asking how many different pairs of lights I needed to turn off (turning off a single pair), in order for no people to be disturbed.

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

    same, the pairwise distinct stuff confusing me, i think that for sample test 1 answer should be 1 because it only need 1 pair to make not disturbed array,

    wasted so much time understanding this problem >:(

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

What's the benefit of hacking someone's submission in Div 3? Does it helps in increasing rating?

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

I tried to hack a solution (It makes 10^12 operations worst case) but I got unsuccessful hacking however the code I tried to hack takes 128s on my machine itself (with T = 100 , it is 1000 in the test case). I want to ask if hacks are only successful if the code gives WA ?

EDIT : here is the link https://codeforces.com/contest/1077/submission/45824799, he is looping from 1 to k/2 when a != b.

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

I read some code and want to hack them. But now my head are getting hacked...

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

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

Can any one tell me why my solution for E is getting TLE on TestCase 51 I think its Nlog(n). http://codeforces.com/contest/1077/submission/45845419[Link to submission].

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

why sometimes there's 3600 participants and sometimes 5000 :/

that's not the first time this happens

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

Дизлайк за МЛ в F2, когда хранишь ДО сверху не по слоям. Можно было спокойно сделать n и x до 2000 и не было бы проблем, ведь аккуратное решение за n^2log(n) все равно не отсечется на таких ограничениях. Ну то есть непонятно, почему ограничения именно такие.

http://codeforces.com/contest/1077/submission/45845944 http://codeforces.com/contest/1077/submission/45846743

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

    Дизлайк за ДО, когда есть очередь с амортизированным извлечением максимума за О(1).

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

    После некоторых обсуждений мы пришли к выводу, что мы хотим, чтобы люди решали эту задачу при помощи очереди с поддержкой максимума на ней, но при этом если кому-нибудь (как Вам) захочется запихать ДО или Sparse Table — то пусть они пытаются пихать такие решения. Мы не являемся ответственными за ваши мысли. Мы и сами прекрасно понимаем, что отсечь при разумных ограничениях O(n2) от практически нереально при такой постановке задачи. Выбор, как решать, всегда остается за участником.

    Между делом, в этом мы хотели дать еще и некоторую учебную составляющую. Такую, что кроме ДО и других стандартных структур данных существуют другие специфичные СД, позволяющие выполнять какие-то определенные вещи быстрее, чем вышеописанные, и что стоит уметь иногда реализовывать и такие структуры данных. Многие участники без проблем написали очередь с максимумами или ее аналоги.

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

In problem E: why is this approach is wrong?

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

Problems like Dick

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

What's wrong with std::list? I used sliding window algorithm for F2 and I used std::list to implement it but I got MLE. So I tried to cut down memory by making D[2][5000] instead of D[5000][5000] and I got accepted. But when I changed std::list to std::deque, it was accepted and even faster! In another OJ sites I usually use, std::list is faster than std::deque so I thought it would be same here. Can anybody tell me why?

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

    MLE code : 45823888 AC code : 45852635 Here is my code.

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

    Maybe list need some extra space to save pointer?

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

      I think so. According to my short experiment using both std::list and std::deque, std::list is faster than std::deque but drains tons of memory. std::deque, on the other hand, uses less memory but slightly slower. There might be something wrong, so if somebody finds anything new, please let me know.

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

        Well... std::list is a doubly-linked list, so for every element in it of type T is uses two pointers and one field of type T.

        std::deque on the other hand is basically a linked list of increasingly large vectors and uses (more or less) the same space as a vector.

        As a very rough approximation, if T has the same size as a pointer, std::list will use more or less 3 times more memory than std::deque. Nothing wrong with it, it's just the way the structures are implemented.

        P.S: Bjarne Stroustrup (the creator of C++) has a very interesting talk on why you should avoid using linked lists. They have their uses (mostly when deletion in the middle is involved), but you should avoid them whenever you can use pretty much anything else.

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

If there is any one want to hack somebody, you can try to hack HunTer's problem C solution, he didn't use long long instead int lol

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

I did 42 successful hacks but didn't get increase in my rank....how it'll be beneficiary for me?

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

I did 42 successful hacks but didn't get increase in my rank....how it'll be beneficiary for me?

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

Comment not applicable

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

I was solving the 3rd problem of round 521 div 3. Problem Link: http://codeforces.com/contest/1077/problem/C As mentioned in question's description that a[i] <= 10^6 but test cases don't follow so. I used frequency array and got runtime error. On the other hand, using map got me AC. Please clarify if I am wrong. Diagnostics: https://imagebin.ca/v/4MtAcprEnUbw RE sol: http://codeforces.com/contest/1077/submission/45860663 AC sol: http://codeforces.com/contest/1077/submission/45862293

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

I was solving the 3rd problem of round 521 div 3. Problem Link: Problem C I don't know why I'm getting wrong for test case 86. But getting right on my local machine here is the code link Solution.

ThankYou.

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

i write this code 45845783 for question D and this gives me wrong answer on test

2 2 1 1

with output 1 but in my IDE this code gives me 1 1 and true output.

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

this 45822434 gives me correct answer for question D in my IDE but this is wrong answer.

can any body say why?

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

Huge difference between cf-predictor & actual rating change!! What's wrong today?

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

    if you "hack" someone by sending inputs that are meant to fail the code you get 100 points if that attempt was successful, likewise the person that was "hacked" will loose their points for the question, as their attempt will be considered a failure. I got hacked and dropped a rank because of it i feel.

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

    I think it's because the predictor is considering non-trusted participants on the calculus

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

MikeMirzayanov in predictor, my increment was +98 but i was increased by +77 in change rate why ??

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

In this round CF predictor shows my rating would be +103 but actual rating increased by +73 :( :( can anyone please tell me the reason why it happens ???

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

vovuh I get WA on problem C with solution 45813685 , but get AC with 45865201. The map might taking some random key with 0 value as I declared map<int,int> and the data can be long long. But why it will take random key instead of taking only the int part(maximum bits that can hold by int type)??? I have checked in the Codeforces custom test section with that test case. It gives same answer as jury's

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

can any one tell me why my solution for E is getting TLE on testcase 54? complexity O(n log^2) http://codeforces.com/contest/1077/submission/45868358

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

Where can I find the tutorial for this contest?

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

Where can I find the editorial/tutorial for this contest?

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

Can somebody explain O(n^2) solution for F? I've seen solutions with sliding windows using deque but I don't quite understand logic behind it.

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

I don't see the tutorial.Can you give me ?

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

My solution to D without binary search passed — https://codeforces.com/contest/1077/submission/45884322 Are the hacks not included in the final test cases when the problem goes into practice section?

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

    Hmm, it is really weird. I will add the test on which your solution will got TLE. It is very strange that nobody do it during the hacks phase. (And even more strange that I don't do it before the round start. Sorry about that.)

    UPD: Woops, this solution got TLE now.

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

      Weird :p Does this mean that this solution would have gotten Accepted in the main contest?

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

        Yes, it was accepted in the main contest, unfortunately. I have nothing to hide. Sorry :(

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

HI in the last two contests thst i've taken a problem that i solved correctly got hacked.does anyone know why?45824931

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

i think div 3 and div 2 contests are same in quality except problem A

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

Whats wrong with my logic for A here:

t = int(input())
for cas in range(t):
	a, b, k = map(int, input().split(" "))
	if k%2==0:
		print(int(k*(a-b)/2))
	else:
		print(int((k+1)*a/2 - (k-1)*b/2))