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

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

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

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

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

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

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

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

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

Спасибо MikeMirzayanov за платформы, помощь с идеями для задач и координацией нашей работы. Задачи были придуманы и написаны командой Университета ИТМО: MikeMirzayanov, MisterGu, myav, Gol_D, Aris, ibraevdmitriy, мной Vladosiya, а также студентом СГУ Brovko.

Также большое спасибо Geothermal, Rafbill, Sugar_fan, mango_lassi, hitonanode, Resende, Igorjan94, CtrlAlt, KerakTelor, FlakeLCR, MatheusMonteiro, Loolo, kocko за тестирование раунда и весьма полезные замечания.

Всем удачи!

UPD 1: Мнение тесторов про порядок задач оказалось настолько неоднородно, что нет никакой возможности быть уверенным в возрастании сложности задач в наборе. Советуем вам прочитать все задачи.

UPD 2: Если вы школьник из Саратовской области, то, пожалуйста, воздержитесь от участия в раунде. Одна из задач может оказаться вам знакома. Спасибо!

UPD 3: Разбор

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

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

Hope the round is not full of problems based on observations only, also I have a question for everyone, how are observations that are in CP problems relevant for any real life problem, cause I suck at observations, and even after solving many problems I am not getting any better, I am on the verge of quitting programming, please I need help.

Hope for a great round!

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

wow, no responses only downvotes, looks like people these days are only competitors not helpers :(

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

First time, registered in Div3 as "out of competition". ^_^
GL & HF

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

Can codechef and codeforces co-ordinate together and one of them shift the date for their 29th dec contest to 30th or 31st dec to avoid a clash?

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

Good luck everyone

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

I hope my rating increases this time

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

more you get more you wish .this is damn true in case of rating also.

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

I think many schoolchild from the Saratov region didn't plan to participate until they see UPD2

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

**Hope we all get positive rank **

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

MNNIT Insomnia has been postponed to start from 10 PM IST. Those who wanted to give the contest can now join in after CF Div3.

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

PS: The opinion of the testers about the order of problems turned out to be so heterogeneous.

"Read all problems".

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

Frequent Div.3 are love..

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

imagine swapping n and m in D

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

The hardest Div3 I have ever seen before :(

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

.

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

Is G DSU and binary search or something else ?

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

    exactly

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

    I have an intuition for Dijkstra, not sure though. LOL

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

    Basically just finding SCCs in a fast way. Even DFS works.

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

      bestial-42-centroids Can you explain your solution, please? Always nice to see deque being used in a solution.

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

        Yes! The first idea is that we want to have some way to know which bombs will explode when another bomb explode. Let's see the explosion process as a graph in which a bomb is connected to another if they are at distance $$$\leq K$$$ and they share some coordinate (i.e they are on the same horizontal/vertical line). Let's consider each connected component. If a bomb from a connected component explodes, then all the bombs of the component will instantly explode. It is know clear that the bomb with the smallest timer of each component will give use the time it takes to explode the whole component !

        The question is now the following: how to find the components. For this let's sort all the bombs by increasing $$$x$$$ coordinates and iterate through the vector (in case of equality for $$$x$$$ we sort by increasing $$$y$$$). This way we can iterate through the bombs from left to right and for each vertical line we'll see the bombs from bottom to top. If a bomb $$$i$$$ is at the same $$$x$$$ than the bomb $$$i - 1$$$, they are on the same line and our processing order over $$$y$$$ guaranty that $$$i$$$ is the closest bomb if we walk to the top from $$$i - 1$$$. So we check if $$$i$$$ and $$$i - 1$$$ are at distance $$$\leq k$$$ and if so we add an edge between the two bombs (using a union find). We should also keep track of the minimum timer of each component.

        Now we know all the bomb components and the time they take to explode. We could use binary search to end the problem but we can also use some greedy algorithm ! Let's put all of this bomb in a sorted vector (in my code it's a deque because it makes implementation easier but you can also use a vector with two pointers).

        The strategy is the following: When manually exploding bombs components, we should explode the components with the biggest exploding time.

        Intuitive proof

        So the idea is to explode the component with the biggest timer and to update the time that has passed. I then use $$$pop_front$$$ to remove the bombs that exploded automatically while I exploded the biggest components manually.

        I hope my explanations were clear! If you have any questions, don't hesitate to ask

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

    My solution for G: Create a graph by connecting edges between two adjacent nodes such that either they have the same X and abs(diff(Y)) <= K or same Y and abs(diff(Y)) <= K. Each node will have maximum 4 edges. Find connected components and let the total components be T. For ith component, assign value i to all nodes in that component. Then, sort the vertices in order of increasing timer and go through them from 1 to N. At ith vertex, add its component value to a set S and update ans = min(ans, max(timer[i], T — size(S) — 1). That's it! Simple dfs.

    Accepted solution: 140115861

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

    Yeah couldn't implement since I kept trying to fix my segment tree solution to E that was getting TLE. Turns out if you use stack you can get $$$\mathcal O(n)$$$ implementation. The last few minutes of Div 3 are always a blur. :(

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

Couldn't think of D and went ahead to AC E instead.

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

Good round! I have no idea what is wrong with my code in E, its sadly. But i enjoyed this round

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

How to solve that D? Was able to solve till F but cant get my mid around D at all?

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

Had similar stupid error in 4 problems... C: forgot to check if s % 100 >= 10 D: forgot to check if 1e9 is OK E: forgot the answer could be more than 32-bit integer G: when removing some debug code, deleted the line sorting the exploding time...

also think about H for 20 minutes without any idea.

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

Implementation Forces

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

OMG, AC problem E 1 minute after the contest ended. I can be at rank 200. what a pity T_T

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

Video editorial for anyone interested

P.S: HD quality should be available in few minutes

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

Thanks for very nice problem set
Missed F just by a minute :(

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

Could any one tell me that at what conditions would we get -1(i.e impossible case) in problem C

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

I dislike the weak example :)

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

Was the time complexity for E O(nlogn)? I had that, but I still TLE. I binary search for the element to "fill in" the gap, and I think others did as well when I click their submission. Does anyone know what part of my code is higher than O(nlogn)? https://mirror.codeforces.com/contest/1619/submission/140082257

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

well too much cheating going on , I know some may say to do hard work instead of talking about cheating but how can a newbie like me out perform cheaters who are doing better than a specialist, it is really becoming hard for us. guess we have to practice like an expert.

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

BinarySearchForces for me.

A really enjoyable problem set, although for a Div 3 possibly a little too hard.

I genuinely thought F < E < D. Maybe I just took a while to figure D out. On the surface it looks like quite an intimidating problem. And F my solution was so simple I was sure I must have misunderstood the question but it passed.

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

    In F there is some severe text understanding skills necessary.

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

    I think people just died on D, cuz they just read it reversed, thinking n is amount shops but rather not friends.

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

      Initially I coded a solution where you were allowed to visit M-1 shops (this is quite easy using prefix and suffix max arrays).

      The N-1 version initially seemed difficult to me because I was trying to optimally choose the best N-1 shops. Once you spot that all you need is at least one shop per person and at least one shop with 2 people for a given target value, it's easy. You firstly have to spot the binary search potential (not too hard) and secondly this non-trivial observation. For a Div 3D I thought it was quite tough, even once you understand the question correctly.

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

    I didn't read F because it looked long and I didn't have enough time (I lost a bunch of time on D because I swapped n and m...and I just had a hard time solving E) but I read G 5mn before the end and insta solved it so for me G < D < E :')

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

    Could you explain your approach for F please?

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

      In each turn, you must assign all N people to one of M tables. Suppose R = (N % M). Then R tables will have X = (N / M) + 1 people on them, (M - R) tables will have Y = (N / M) people on them.

      In the first round, assign the first R * X people to tables with X people (big tables), and the remaining people to tables with Y people (small tables). Store the index i_small of the first person at a small table in this round.

      In the next round, begin your assignment of people the big tables from i_small, and repeat the process.

      Why does this work? We're cycling through the guests from 1 to N in blocks of R * X. As such, no person is ever more than 2 big tables ahead of any other.

      (Note that in the case R = 0 all guests are always sat at small tables).

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

Does anyone know what I have done wrong in problem C https://mirror.codeforces.com/contest/1619/submission/140095282 Thanks a lot!

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

It's hard for me to solve these 8 problems in 2 hours.The duration is short.

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

I found code that goes against the rules. What should I do? https://mirror.codeforces.com/contest/1619/submission/140060952

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

C was so cancer :( .

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

In today's problem C, i submitted my code(language: c++17) during the contest at 2:02 while the contest was still running, I got runtime error on test#1 but same code runs fine on changing language to c++17(64), I also ran same code on test#1 in atcoder compiler and it worked fine there

also when I add if(v2.size()>0) before this for loop for(ll i=v2.size()-1; i>=0; i--) { v3.pb(v2[i]); }
same code got accepted but this addition shouldn't matter.

link to runtime error code: 140087080 link to accepted code: 140095620

please look into this @MikeMirzayanov @Vladosiya

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

The contest was profoundly unbalanced but the problems were interesting still, thanks!

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

Can anybody please help me in finding what is wrong with my code for D. Any counter testcase would help.

WA on tc 2 140096931

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

Why in B the solution which having the ans by formulas getting hacked??

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

If anyone's getting runtime error in C try defining your own stoi function rather than using the standard one I dont know why this works tho :(

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

Hi everyone This is my first Codeforces contest and I see that now there's a hacking stage. I know you're meant to try and break other people's code but does someone know where I can find the details, please? Many thanks

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

I solved D with binary Search.

Simply Binary Search over the answer and check for the following two conditions :-

(1) All friends must have at least one joy value which is greater than or equal to our mid(checking for mid) value.

(2) There must exist at least one shop from which we can buy two gifts for our friends with value >= mid because we can visit at max n-1 shops because if we can buy two gifts from a single shop then simply we can visit all other shops to buy left gifts.

For more clarity look at the submission 140061439

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

    We are checking two numbers greater than mid for any shop so let's say there exist two numbers greater than mid and all the rest conditions are also fulfilled then we are taking the answer as mid(which doesn't exist in the array) , so how are you assuring that the final answer will exist in the given 2-D array. Will the binary search cover all the cases ?

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

      Yes it will

      Suppose for a certain mid value which does not exist in the array both conditions are true

      at that moment we are intializing ans to mid and changing left bound to mid+1 which means for the next value greater than mid which is present in the array ans will be true and our mid value will visit that particular once and our ans will be maximised there

      I hope you understand

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

    you can make it easier

    1. for each store find a gift A with the largest joy and gift B with the second largest joy (max and second max in each row)

    2. сhoose the store X with the maximum B value

    3. for two friends, take these two gifts in the store X

    4. for another friends take a gift with larges joy without limiting the store (max in column)

    all calculation is performed in one pass O(n*m)

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

Can someone tell me why this solution is giving WA? https://mirror.codeforces.com/contest/1619/submission/140060676

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

Oops I thought it's div 3 .

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

Problem d is so difficult to understand, how to solve it

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

Great round with high quality samples (especially for problem D!) The problems where overall very interesting (it could be more balanced but I just read UPD 1 which is fixing this problem) The little bad point I can find is that problem F statement is way too long

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

https://mirror.codeforces.com/contest/1619/submission/140090821

can someone pls explain why I get a runtime error on case 2. My code seems to work for every test case I try.

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

What could be done in D if we have to visit atmost K(any arbitrary number) shops instead of n-1 ?

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

    I believe in that case the problem becomes NP-complete. We can reduce the vertex cover problem (which is known to be NP-complete) to the problem you proposed. But first, let's assume that $$$p_{ij}$$$s can only be $$$0$$$ or $$$1$$$. Therefore, your problem becomes: are there at most $$$K$$$ shops such that we can buy $$$n$$$ gifts of joy value $$$1$$$ for each of our friends?

    Now let's get back to the vertex cover problem: Given a graph $$$G(V, E)$$$ and $$$K$$$. Does $$$G$$$ have a vertex cover of size at most $$$K$$$?

    To reduce vertex cover to your problem, we map each input of vertex cover to some input of your problem.

    For any vertex cover input ($$$G(V, E)$$$ and $$$K$$$), you can assume that the set of vertices $$$V$$$ is the set of shops, and the set of edges $$$E$$$ is the set of your friends. We set $$$p_{ij}$$$ to be $$$1$$$ if the $$$i$$$-th vertex is connected to the $$$j$$$-th edge. Otherwise, we set it to $$$0$$$. So now, the number of shops is $$$|V|$$$, and the number of friends is $$$|E|$$$. If you can find $$$K$$$ shops from which you can buy $$$|E|$$$ gifts for each of your friends, then you have found a vertex cover of size $$$K$$$. Hence, the problem you proposed is NP-complete which almost implies that there is no polynomial algorithm to solve it.

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

      not exactly sure what you mean, " no polynomial algorithm to solve it." I solved using binary search, thing is it does not leverages of fact of going to "n-1" shops, so you can just change to k. You can check my submission.

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

        The issue is not with the binary search part. The issue is that when you fix some value $$$x$$$ (the midpoint of the binary search), you cannot use the same logic to "test" whether you can have the answer equal to $$$x$$$. In the original problem ($$$n-1$$$ shops), you can check that:

        1. For each of your friends, there is at least one shop with a gift of value $$$\geq x$$$.
        2. At least one shop can support at least two of your friends.

        The same logic cannot be applied when you are restricted to up to $$$K$$$ shops. In other words, you cannot adjust condition 2 to apply to the case with $$$K$$$ shops.

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

Again not div.3 contest :(

Again the difference is only in format, but not in difficulty. If you don't like to make contests with rooms and hacks, pls use the format name "Educational", which is also nonsense, because any round is educational — has discussion and editorials after it.

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

hope to get the last 30 rates

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

is there any solution about this contest?

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

In problem "Wrong Addition"

Here is My Solution

Description of my approach

Edit: I got my mistake but why that mistake is happening I didnt get it In my code I have checked for val2-val1>9 but i was not checking val2-val1<0 that is why it was showing WA but as soon as I included it it got accepted. Can someone please tell me why it is relevant to check < 0 condition?

Here is my correct solution

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

Can someone tell me why my dp based solution failed on problem d 140078987

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

Thank you for the contest. orz. Where's the editorial?

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

I think that it is too difficult to be a div3

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

ratings not out yet?

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

why is it that usually div3 contests take a lot of time in testing and updating rating where as div2 contests take much lesser time?

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

why penalty even if i didn't make any wrong submission ?

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

vovmr , anime lover, KOVAL_ is same acc?

the 3 had almost same coding and F submitted in 1min?!

added Kireev_Andrey

Standings, UserName 3. KOVAL_, 4. titanoBEBRA, 5. imsigma, 12. Kireev_Andrey

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

Hi, In Problem B (Squares and Cubes), I found a direct formula to calculate the numbers. But when I implemented in Python and tested it locally, it gave wrong answer for big numbers (1e9). I used the same formula in C++ and it got accepted.
Python Submission 140133787
C++ Submission 140033550

If Problem setters hadn't given the big testcases in Example, I would have lost too much time tracking this error. How can I avoid this error. It seems to me like a floating point operation error.

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

    You can solve it easily by noticing that when calculating roots of numbers to some power, there is always some error, the error being the root of the number is generally some number below the desired result. For eg, 1000000000 cube root of this in python will give 999.9999999999997, So for numbers till 10^9 as a limit in question, the answer is generally just the perfect cube root or some number bit smaller than our perfect answer. So to solve it, just check if we get x=int(pow(n,1/y)), than try for (x+1)*(x+1)..y times<=n or not, if it is than it means x+1 should also be taken in consideration. So, now x=pow(1000000000,1/3),int(x)=999. So after checking 1000*1000*1000<=1000000000, we will take 1000 into consideration instead of 999.

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

    ur one line solution is good....can u please explain the last part --(ll)(sqrt(cbrt(n))

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

      sqrt(k) and cbrt(k) are built-in functions in c++ math library. They find square root of k and cuberoot of k, respectively. if I write sqrt(cbrt(k)) , Here I'm finding 6th root of k. To Find all the square roots and Cuberoots, I am finding all the square roots first (1, 4, 9) then all cuberoots(1, 8,27..) some numbers might come in both(64, 729..) So subtracting those.

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

There are many people who cheat in a very stupid way. This is what they revealed to us. They solve more than 2 problems in a minute or two minutes and their level is not high at all. Please take the appropriate actions with them and please add a feature on the site to detect these cheaters.

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

In case you are looking for Video solutions.(for A-E only)

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

Regarding Problem C, my AC solution, this solution works fine even when accessing indices<0 from string s. I understand that accessing out of bounds need not always give a runtime error, it rather generally is unexpected behaviour. However since the solution was able to pass all the pretest and main tests, I wanted to clarify that was it all luck or is there any specific value one should expect when accessing negative indices from string (particularly -1). thanks in advance, any help is much appreciated.

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

why no editorials yet?? How to solve H?

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

feeling so happy i am getting specialist first time from this round

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

I got a mail from codeforces that's my solution is coincides with two other participants of problem D. And yeah their solution is quite similar to mine I don't know how they got my code (I'm the one who solved it first). I also compare both the solutions using moss the plag is just 46% So maybe it is just a coincidence. I don't even know these two participants I didn't use any online compiler during the contest. Also, one of them is already an expert so for him this contest is unrated So there is no point in sharing my code with him. another thing is if I did share my code I won't be writing this comment. I really worked hard for this contest and I request you to please look into this matter and do the needful. Thanks a lot

Vladosiya MikeMirzayanov

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

I got hacked and it seems that the output differs on codeforces and elsewhere. On few computers I tried to run my algorithm against algorithms made by other people and they gave the same answer.

Is it possible to know on which platform codeforces run to debug the issue? It seems that codeforces long double is not that long :D.

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

Any hints on E MEX and Increments?

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

    Try calculating least steps needed to get atleast one occurence of i for each 0 <= i <= n. Then the solution logic is straightforward

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

    if you know how many steps it takes to have all the values 0..k in the array ( impact_num )

    and you know count of k+1 in source array ( cnt[k+1] )

    then answer for k+1 will be impact_num + cnt[k+1]

    it remains to calculate impact_num for the next step

    if cnt[k+1] > 0, impact_num will not changed

    if cnt[k+1] == 0, you must find cnt[j] > 1 where j < k+1, decrease cnt[j] and impact_num += k+1-j;

    an effective structure for such a search is a stack

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

      What is k here?

      • »
        »
        »
        »
        4 года назад, скрыть # ^ |
        Rev. 3  
        Проголосовать: нравится 0 Проголосовать: не нравится
        It is not just to get k, the before shouldnt be disturbed.
        
        If there is no 5 then to get 5 you need something from 0,1,2,3,4 to repeat. If all are single then there is no way to get all 0-5. So for example 0,0,0,4,5
        
        steps[0] = 0 # Already present
        steps[1] = 1 # I can increasing one zero
        steps[2] = 2 # One more extra zero is present so can increase
        steps[3] = -1 # There are extras left, all available extrasare used for till last value
        So it is not possible to get mex value > 3 from the array. So we take -1 for 4, 5.
        for lower values, i.e, for example to get mex value 3 we need 
        steps[3-1] + count[3] i.e., (acheive all values till 3 &mdash; 1) + (convert all 3 to 4) which makes mex value as 3
        
»
4 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

This round isnt rated?

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

Is it rated?

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

Is it rated?

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

All I needed was 1 more point. Curse that long long int on test case number 4 of question E.

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

Still waiting for the editorial :/

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

When will the editorials of this contest be released ?

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

When will the editorials of this contest be released ?

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

Excited for the contest, Always love the CF round.

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

How to solve H ?

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

    How to solve F and G :)

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

      f is construction. you need n%m players sitting on greater part of table (having more player than others). n≥2m -- means if you add layer by layer, they never intersect. like : 111100000000 , 000011110000 and so on. where series of 1's represent the player idx sitting on more greater part of table. n -- people, m — tables. n%m is the length of ones, means it is < n/2.

      g is connecting the points by x than by y. (sort by any cor. say if i and i+2 connect, then i and i+1 and i+1 and i+2 also.) so just add these 2 edges. every connected component will blast at min time of each those points. store these in a vector and binary search on minimum number of moves required. Say you do 5 moves. you do not need to blast those having less than 5 seconds as minimum time. but all those having greater time than this (say # cnt). if cnt <= your_choosen_time. then it is possible else not.

      --- if you do not understand wait for editorial.

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

Where is the editorial? Can anyone tell their logic for H ?

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

    First, note that every element of the permutation is part of a cycle if you keep doing $$$i = p_i$$$. We have two possible approaches the first is to keep all cycles using a heavy structure like treap or splay tree, then operation 1 you basically have to cut the corresponding cycles and merge than in the correct form, and operation 2 is somewhat easy you just need the cycle size and know how to find the k'th element of a cycle and the position of a given element on its cycle complexity $$$O(nlogn)$$$. The other aproach is to every element you save the next and previous element on its cycle as well as where you ended up if how make $$$i=p_i$$$ $$$sqrt(n)$$$ times, its possible to do every update of type 1 in $$$\mathcal{O}(sqrt(n))$$$ and answer every query of type 2 in $$$\mathcal{O}(sqrt(n))$$$, you use jumps of $$$sqrt(n)$$$ size until you can't make anymore, and then you make at most $$$sqrt(n)$$$ jumps of size 1 to end up where you want, the complexity of this second approach is $$$O(n sqrt(n))$$$ and it's much easier to code.

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

      Thank you ,i was doing it with dsu but was not come up with a solution on how to use path compression on dsu so got tle on test 13 .The above idea is great ,but do you know how to do the problem with dsu ?the main problem in using dsu is how to do path compression so it doesn't take long enough time to compute values

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

why my solution for c fails? please help what is it that I am missing? https://mirror.codeforces.com/contest/1619/submission/140180338

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

Editorial Please.

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

please help ! multiset is not working properly on codeforces it is giving wrong output, but it works fine on local (problem E)

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

why the answer of

4 4

3 1 2 7

10 3 9 9

8 1 4 7

1 7 9 3

in [problem:D] is 9 but not 7.

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

exactly i dont know what i know Esquire MohammadParsaElahimanesh

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

Nyaharo~~