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

Автор vovuh, история, 4 года назад, По-русски

<almost-copy-pasted-part>

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

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

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

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

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

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

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

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

Удачи!

</almost-copy-pasted-part>

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

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

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

Good Luck to all participants!

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

Честно говоря мне очень нравится Div.3 раундах особенно когда создатель vovuh или pikmike

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

I know there is a Points Penalty of 50 points but what is the Time Penalty all about?

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

    Educational CF Round and Div.3 Round have no points penalty. Instead, they have time penalty, which depends on the time when a participant submitted correct submission and the number of wrong submission. In detail, if you solved problem k minutes after the start of the competition, your solved problem number increases by 1, and your penalty increases by 10×(the number of wrong submission on that problem)+k.

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

Looks great! Maybe this is the round when I finally become rated. ;O

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

    Why are you so eager to become green?

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

    you can't because this contest is only rated for trusted participants. And the criteria being trusted is

    1. take part in at least two rated rounds (and solve at least one problem in each of them)
    2. do not have a point of 1900 or higher in the rating.

    and you didn't participate any contest till now.

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

      Regardless of whether you are a trusted participant of the third division or not, if your rating is less than 1600, then the round will be rated for you.

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

I registered when I was cyan (during previous Div.2 contest) and now my Handle in registrants list doesn't have a star(*) next to it . Is it gonna be rated for me and people like me or not ? If yes I hope you fix it cause I don't think it's gonna be fair this way.

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

    you can deregister yourself by going to the registants page and click the red x button :D

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

Come on!!!

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

Can my rating increase or decrease if I am an unofficial participant and I take part in this Div3 ?

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

Vovuh and Codeforces div3 rounds.

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

Screenshot-from-2020-02-04-16-03-55)

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

what about the score distribution?

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

getting negative recent vovuh's contest

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

I am late some minutes. Is it not possible to register after contest has started?

I am not able to submit :/

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

Can we hack any solution in this contest ? When does it start ?

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

How to solve E?

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

    Solution for $$$E2$$$:

    Firstly observe that the question asks to use minimum number of colors such that subsequence formed by each color is sorted.

    Consider the longest decreasing subsequence (LDS) of the given array. Observe that no two elements of this sequence can be given the same color, hence number of colors must be greater than or equal to the length of the LDS.

    Now, to find a coloring with number of colors equal to length of LDS, let $$$lds(i)$$$ denote the length of longest decreasing subsequence which ends at $$$i$$$ and includes the $$$i$$$th element. Observe that if $$$a_i > a_j$$$ with $$$i < j$$$, then $$$lds(j) > lds(i)$$$. Importantly, $$$lds(j) \neq lds(i)$$$. Thus, you can just assign the $$$i$$$th element the color $$$lds(i)$$$.

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

      But LDS will take n^2 time right?

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

        No. You can find LDS in $$$O(n \log{k})$$$ where $$$k$$$ is the size of the alphabet using binary search/fenwick tree/segment tree. Even a simple $$$O(nk)$$$ algorithm will work for this problem. Search online for LIS solutions.

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

      Nice construction. Thanks!

      By the way, how did you come up with this LDS construction. It seems so..... exotic. It's really very nice.

      Had you encountered a similar problem before, or did you come up with the solution from scratch?

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

    You can also just check that a letter can't be assigned to the same color of any letter that has greater value and appears before (it is an inversion). I assigned bitmasks to every letter and every mask will have a bit of the corresponding color active if there is a letter that was already assigned to that color.

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

What's the reason 70267449 'Compilation Error' in C++17 but the same 70270849 worked on C++14 ?

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

I signed up for this div3 before the score reached 1600.Can anybody tell me that Will I be rated in this situation?Thanks~(I didnt find the star '*' beside my name during the competition)

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

STLforces :)

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

Can someone explain to me how does the Test Case #1 for question-d is correct?

TC:
6 2 3 3
7 10 50 12 1 8
Answer: 5

I keep finding 6.

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

    You need 2 tricks for 10 and 50 (10-2-3-2-(?)-2-(?)-2), same mechanism for 50. So you can't have 50 and 10 simultaneously

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

    first , fourth and fifth monster can be killed without secret technique . Last monster can be killed by using technique once and rest of the monsters can be only killed using technique twice .

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

GreedyForces

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

My rating is less than 1600 now, but why I'm not in the official standings of the contest?

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

hello I'm new to CF great problems! I like E2 and F very much

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

Fun fact: if you change statement of E2 so that you have to color all occurences of a fixed letter the same color and let alphabet size vary, you get an NP-complete problem by reducing to graph coloring.

UPD: no, that's actually wrong. Reduction I was thinking about was associating every vertex a single letter and then finding some permutation such that the graph is what you want. But that is wrong: there are $$$ n! \sim \sqrt{2 \pi n} \left(\frac{n}{e}\right)^n $$$ permutations but $$$ 2^{C_n^2} $$$ graphs and there is no way to have a surjection.

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

What is wrong with thislink for problem A(div3).

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

my solution to C

can anyone tell why this fails on test case 6? I transformed the string into integer array and used greedy approach to find the smallest sub array with 0 sum.

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

    Using +2 for "UP" and +1 for "RIGHT" means that your program thinks "ULL" is a net-zero sequence of moves. You could do some approach like this, if you did +N for "UP" and +1 for "RIGHT", then there would be no ambiguity because it would be impossible for enough L's to cancel out a U. Or you could just keep track of the sum into two parts, a netVertical and netHorizontal.

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

      but i am never considering odd sized subarrays, I am only checking for even sized subarray starting with 2, hence, I will never check for ULL.

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

    1 6 UULLLL

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

    just replace 2 with 10^6 but your code will still be tle, try hashmap, changed solution of yours it passes test case 6 my solution with hashmap with linear time complexity

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

I didn't solved a single problem, I feel so dumb right now...

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

    everyone didn't solved a single problem at the first time... cheer up man practice hard and get ready for the next contest.

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

    @Ernis In the Codeforces Educational Round #81, I am also not able to solve a single problem. But in this contest, I performed decently. So just compete and don't give up.

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

    Try to upsolve problems after contest has over ..its better for U

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

Are there some extra spaces in Test case 6 of problem C? Using s.length() in C++ was giving runtime error while replacing it with n gave wrong answer.RE WA

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

can we solve E1 by using bubble sort to generate a graph where there is an edge between two letters if we have to swap them, then check if this generated graph is a bipartite graph ?

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

How to solve F?

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

    Sort the query asked by passenger in increasing order of minimum distance in path.

    now let for query(a,b,g) if i already assigned all edges with cost less g and assign all edge in path from a to b with g(if any edge is already assigned with less cost then reassign it with g) then minimum cost for a path can't be less than g. Since i am assigning the cost in increasing order then it might be the case that minimum cost in path from a to b can be greater than g(let after reassigning all edge with cost>g). So assign cost to all edges that come in path for every query in increasing order of cost and after processing all query check the minimum cost for every path in query if it doesn't match then there is no valid answer. if every query matches then we have the answer.

    here is my submission

    I solved it in O(n^2) but i am curious to know any soln with less complexity.

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

please give idea to solve C & D

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

    For C

    Store the current location while iterating you can begin at (0, 0) increase the values accordingly for L, U, R and D

    Store the last seen locations in a map or set and when you reach a point you've seen before check if the distance between the current index and index of where you last met the point is minimum and save it as your result.

    For D

    Calculate the number of tricks (the secret technique) you will need to gain points from each monster ignore if 0 (add 1 point to the result since you already earned it) sort the other trick values and pick from the minimum while k is sufficient

    You will need a trick if h mod (a + b) = 0, you need exactly ceil(b / a) tricks for that

    Or if h mod (a + b) > a let's call the remainder rem you need exactly ceil(rem — a / a) tricks for that.

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

Round has ended recently and now I'm really can't explain why my E2 solution works

Interesting experience :D

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

70254356 Why doesn't this solution end up in TLE? If we consider the number of operations it should be slow. I tried the same solution in GNU C++ 17 in custom invocation and this solution ends up in TLE but in MS C++ 17 it passes easily. Is there some kind of optimization in MS Visual C++? What am I missing here?

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

.

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

So someone replaced D with C .

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

How to solve E using graphs ??

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

I feel that C was comparatively difficult than D.

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

What is the hack case is F? pajenegod

UPD : It TLEed

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

    I was doing TLE hacks. In the end I was able to hack more than $$$100$$$ submissions with the same hack. My test was just to construct a tree in the form of a line, then do queries from one end to the other with weight $$$10^6$$$. To make the queries a bit heavier I made all the labels random and never asked the same query twice.

    One fun thing to note was that my test case hacked the checker for the problem.

    I've seen my hack take $$$46$$$ ms submissions to $$$1.3$$$ s, so my test was far heavier than the original test cases. Honestly the reason why my hack was so effective was because the original $$$267$$$ test cases were really sub-par. Not only did they not test the obvious max case, there were also obvious patterns in the data. For example if you made node $$$1$$$ be the root, then parent[i] < i in every single one of the original $$$267$$$ test cases. dorijanlendvaj noticed this pattern after I showed him a $$$46$$$ ms submission that I had made TLE. He figured out that the code got stuck in an infinite loop if parent[i] > i, which never happened in the original test cases.

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

Don't know about you guys...For me this is the best contest ever...

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

Why are some experts getting rated ?

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

My submission was TLE on System test. https://codeforces.com/contest/1296/submission/70275201

I submitted same code and got AC. https://codeforces.com/contest/1296/submission/70355834

Does this happen often?

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

in question C for 3rd division cant we use prefix-sums and check for sum of 'L' & 'R' for size 2 and sum of 'L'+'R'+'U'+'D' in the string and print the index where we get it.... what is wrong in this approach!!! on which edge case it might be wrong!! please help

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

Hello, could someone help me check my submission for problem F? It got time limit exceeded on test 271. I already check it in my computer with a line graph, and it is slow (took around 7 seconds). I have no clue why it happened. Submission link: https://codeforces.com/contest/1296/submission/71952020. Thank you!