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

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

Всем привет!

В воскресенье в Москве пройдет XIX Московская командная олимпиада — командное соревнование для школьников, проходящее в Москве как отборочное соревнование на ВКОШП. Над туром работала Московская методическая комиссия, известная вам также по Открытой олимпиаде школьников по программированию, Московской олимпиаде для 6-9 классов и олимпиаде Мегаполисов (раунды 327, 342, 345, 376, 401, 433, 441, 466, 469, 507, 516, 541, 545, 567, 583, 594, 622, 626, 657, 680, 704, 707, 727).

Раунд состоится в 25.10.2021 09:35 (Московское время) и продлится 2 часа. Обратите внимание на нестандартное время начала раунда. В каждом дивизионе будет предложено по 6 задач. Раунд будет проведён по правилам Codeforces, будет рейтинговым для обоих дивизионов.

В связи с этим мы просим всех участников сообщества, участвующих в соревновании, проявить уважение к себе и другим участникам соревнования и не пытаться читерить никоим образом, в частности, выясняя задачи у участников соревнования в Москве. Если вы узнали какие-либо из задач МКОШП (участвуя в ней лично, от кого-то из участников или каким-либо иным образом), пожалуйста, не пишите раунд. Участников олимпиады мы просим воздержаться от публичного обсуждения задач. Любое нарушение правил выше будет являться поводом для дисквалификации.

Задачи соревнования подготовлены LHiC, cdkrot, isaf27, AlesyaIvanova, Tikhon228, voidmax, fedoseev.timofey, KiKoS, NiceClock, 4eT_llpuyHblJl, vintage_Vlad_Makeev и Дарья Крохина под моим руководством, а также GlebsHP, meshanya, Endagorion, Zlobober и Андреевой Е. В.

Спасибо adedalic и KAN за координацию раунда и вычитку оригинальных задач МКОШП, adedalic и GlebsHP за перевод условий, а так же MikeMirzayanov за системы codeforces и polygon, который использовался при подготовке задач этой олимпиады.

Также спасибо napstablook и Anti-Light за предоставление дополнительных задач, которые помогли составить (я надеюсь) сбалансированный проблемсет для раунда.

Всем удачи!

UPD1: Спасибо Um_nik, PurpleCrayon, LHiC, VladaMG98, JovanB, TadijaSebez, AlanSkarica, Markadiusz, actinium16, jurichhh8 за тестирование.

UPD2: Разбалловка:

Div.1: 500 — 1250 — 2000 — 2250 — 2250 — 3000

Div.2: 500 — 1000 — 1500 — 2250 — 3000 — 3250

UPD3: Разбор

UPD4: Победители!

Div. 1:

  1. djq_cpp
  2. ksun48
  3. maroonrk
  4. ko_osaga
  5. Radewoosh

Div. 2:

  1. zero4338
  2. C2020jzm
  3. SYDevil
  4. PPL_
  5. just_ice
  • Проголосовать: нравится
  • +267
  • Проголосовать: не нравится

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

Why is it on Monday at 14:35? We're still at school...

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

    In my region the contest is at 1 am. I need to wake up at 6 am to go to school D:

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

    Please consider others. Not everything is for you.

    P.S. I really love this round! Really good pretest. There's even a n=1 pretest so that I would not FST.

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

Did this have only 2 comments before? [It says the blog has been posted 2 weeks ago.]

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

    The blog was written 2 weeks ago but published recently.

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

      I thought, I saw this post before and assumed it was republished. But there were no comments. And got confused. thanks for reply :)

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

Is it going to be held in the ICPC 10mins penalty format or score distribution will be released?

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

For europe this is a ridiculous time

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

i wish contests timings will go back to normal...

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

In problem E in the last sample, why [7 9][7] is impossible?

Thanks.

EDIT: Nevermind. I was too hungry when I read the statement.

EDIT: Looks like I was so hungry that I commented on the newer contest's announcement. Apologizes for spamming.

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

This should be the most unusual time I've ever seen in Cf

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

Bad time

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

I hope there will be more datastructure problems . I like that more than construction problems.

Hope everyone good luck!

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

waiting for aryanc403's pigeonhole comment

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

As a student, who has already participated in this olympiad, I say that problems are good.

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

Oh 22:35, note the usual time!

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

As a tester, the problems are great! Good luck to everyone! :)

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

As a tester, I can confirm that the tasks are very interesting, and the statements are clear and well written. I hope you enjoy the contest. Good luck!

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

If you test a round but don't shamelessly beg for upvotes in the comments, can you really call yourself a tester?

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

I guess orzdevinwang will become LGM after this contest!

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

    sadly the contest contains some unfair problem which is 100% not original and meaningless,we have to wait longer...

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

Waiting for weak pretests.

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

nice contest but still at expert :'(

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

OMG , this contest will give me one of my best rank if there will be no FST , I m so happy

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

Div.2 D is so hard for me :(

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

FML for never improving my bit manipulation concepts, didn't even get close to solving C.

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

Just for sure, is problem D bfs?

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

    tem_shett thinks that yes!

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

    Kind of... At least in my case, I solved it with a DP + queue, where the DP states are propagated using a queue, sort of like in a BFS fashion

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

    Yes, 0-1 BFS backwards from the top of the well on the state {current position, next event is a slip or jump}.

    Slips (zero cost move) can be easily maintained as an adjacency list and jumps (1 cost move) are just marking all positions where $$$j - a_{j} \leq i$$$ when we are at $$$i$$$. So we can just sort all points by values of $$$j - a_{j}$$$ and process as many unprocessed ones from the start as we can in each step.

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

      I've seen your code but I still don't get how going through the 'order' vector only once is enough. Could you please explain that?

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

Is range addition + range min queries segtree not intended in Div1C or is the TL just really tight?

Had to switch to ints and replace two sets with vector + sort + unique to even go from TL2 to TL13, I half expect replacing the remaining maps in this fashion will fix TLE :/

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

    I've got OK with seg-tree queries that you mentioned. But only after switching from __gnu_pbds::tree to BIT in computation of number of inversions in a[].

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

      I used a BIT from the start, still TLE on 13 :/

      I suspect I'll need to remove the majority if not all the maps in my code to get AC.

      Edit: Yup, removing all maps and using a sort based compression instead was enough to get AC.

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

How to solve div2 C?

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

    check for each bit the frequency among all numbers($$$f_0$$$ ~ $$$f_{29}$$$), find the GCD for the freq among all bits($$$gcd(f_0, f_1, \cdots, f_{29}$$$), the answers are all the factors of the GCD value.

    also, remember to handle the case where all numbers are zero.

    updated: the special case should be all numbers are zero instead of equal

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

      How did you came to this and plz explain why it works.

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

        the idea came to me after I write down the numbers in base-2.

        why it works: for a bit $$$i$$$, let's say it occurs $$$f_i$$$ times, it will be subtracted only when all $$$k$$$ chosen number in that round has that bit, which means that $$$k$$$ has to be a factor of $$$f_i$$$.

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

    Count the setBit of all position from 0 to 30 of all element. Run a loop from 1 to n and check if the mod of i and count of setBit in all position give zero then it is possible to distribute for I

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

Why is Div1C time limit so so tight.

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

    +1. I pass it by using a quicker input ways .

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

    I don't get why authors set problem with complexity O((n+m)*log(n+m)) n,m<=1e6 with non-trivial constant.Even the time taken by the accepted submissions is very high.Is it intended to use getchar while taking input?.Would never have happened if anton coordinate the contest

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

    You can search optimal positions not fair, but with ternary search + checking small neighborhood. Constrains was raised against such solutions.

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

      You do realize that because of blocking some weird heuristics many genuine solutions were not allowed?There are 6 pages of TLE in this problem and most accepted submissions are close to tl

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

      If very tight tl is intended why not have ai,bi<=1e6 instead of 1e9.

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

Problem 1D/2F is a problem of a private contest in our school.. I'm so amazed..Here is the photo

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

how to solve Div.2 D?

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

"Dp with data structures" round ...

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

Wondering why BFS solution for DIV2-D got TLE? The complexity would be O(ElogE)!

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

Wondering why BFS solution on div2-D got TLE. The complexity would be O(n.log(n)) which is fine!

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

My idea for D was the following:
Since an alpinist $$$j$$$ can come after alpinist $$$i$$$ only if $$$\max(s_i,a_i) \le s_j$$$ so we can first sort the array by $$$s_i$$$ values and say for each index $$$i$$$ the value of max length subsequence ending at this index is $$$DP_i$$$, recurrence would be,

$$$ DP_i=\max_{x \in [0,s_i]}DP_j+1 $$$

And this could be done with a segment tree where after reaching each index we update the $$$\max(s_i,a_i)$$$ index in the segment tree by $$$DP_i$$$ Is this solution anywhere close to the original solution?
EDIT: Okay, I read the editorial and this approach is incorrect:(

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

I really liked problem C. If you construct $$$n \times 30$$$ binary grid of the number's bits, we are essentially taking maximal (vague but it doesn't matter a lot) all one subgrids (in the subseqeunce sense) with column size $$$k$$$ and flipping them to zeroes. This shows that the value of $$$k$$$ should divide all the column sums in all the $$$30$$$ columns. And it's easy to check that it is possible to do the latter when $$$k$$$ does satisfy these conditions.

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

for C, k is in the answer if and only k divides all sum of 1 in 30 columns bitwise? I couldn't prove the correctness but passed pretests.

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

For problem C, is it true that k is in the answer set if and only k divides all count of 1 in 30 bitwise positions? I couldn't prove correctness but passed pretests

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

    Yes and the proof is not hard either.

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

      what is the proof? the condition of k divides is obviously a necessary condition, but how do you prove is it also a sufficient condition?

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

        Consider any divisor $$$k$$$ and a set of numbers such that the count of numbers with the $$$i$$$-th bit on is a multiple of $$$k$$$.

        In each step, choose any set of $$$k$$$ numbers which share at least one same on bit. Clearly this is do-able as long as all the numbers are not zero and the condition that count of numbers with the $$$i$$$-th bit on is a multiple of $$$k$$$ is maintained.

        Now the $$$\textbf{and}$$$ of these numbers will only include bits which are on in all the numbers. So we will reduce the count of numbers with the $$$i$$$-th bit on by $$$0$$$ or $$$k$$$ for each $$$i$$$.

        So the count of numbers with the $$$i$$$-th bit on will remain divisible by $$$k$$$ and we can repeatedly perform this to solve it.

        If you want a more formal proof, you can write a strong induction proof using this fact. The predicate would be something like $$$p(x)$$$ means for any positive integer $$$k$$$ there exists a way to solve an arbitrary set of non-negative numbers with sum $$$x \times k$$$ given that the count of numbers with the $$$i$$$-th bit on is a multiple of $$$k$$$.

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

    every time we want to subtract, we need to subtract k or 0 counts of bitwise pos, so if we want to subtract all elements to zero, the bitwise count in every pos must be divided by k

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

I accidently do my best ever contest in my alt account but not my main account

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

very super legendary strong pretest in B :( Unbelievable :(

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

In problem B (div 2), what is the maximum value of k after which the there is no change? I thought it would be N, but that failed pretests. Running an infinite loop and breaking when the array becomes constant worked.

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

To not keep you waiting, the ratings are updated preliminarily. In a few hours/days, I will remove cheaters and update the ratings again!

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

About problem D,I submitted a simple code and it passed system test.
Could anybody Hack it or prove that it is right?

int n,d,ans;
struct P{int s,a;}a[N];
bool cmp(P x,P y){return max(x.s,x.a)==max(y.s,y.a)?x.s<y.s:max(x.s,x.a)<max(y.s,y.a);}
signed main()
{
    rd(n);rd(d);for (int i=1;i<=n;i++) rd(a[i].s),rd(a[i].a);
    sort(a+1,a+n+1,cmp);
    for (int i=1;i<=n;i++) if (a[i].s>=d) ans++,d=max(d,a[i].a);
    cout<<ans<<"\n";
}
  • »
    »
    3 года назад, # ^ |
      Проголосовать: нравится +44 Проголосовать: не нравится

    I tried to prove it by swaping adjacent positions.Let's suppose that $$$\max(s1,a1)<\max(s2,a2)$$$ and now we swap them.If $$$a2>\max(s1,a1)$$$,the answer will be obviously smaller.If $$$s2<a1$$$,we can find that $$$a2>a1$$$,so the answer may be smaller,too.

    I haven't found a situation that we can make the answer bigger by swaping adjacent positions,so I guess it is right.

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

      But why you explain this to your classmate in English through Codeforces?(I mean that they are classmates and they are both Chinese.It is convenient for them to communicate with each other in private.)

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

I am really surprised to see why div2 winner of this contest having less number of question solved as well as contest also.

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

About E2/C1 problem. Does anyone have the way to construct the final array with A and B elements. Because my only problem is to construct this array.

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

    For each $$$b_{i}$$$,we use $$$c_{j}=1,0,-1$$$ to denote $$$a_{j}>b_{i},a_{j}=b_{i},a_{j}<b_{i}$$$ respectively,so the cost of inserting $$$b_{i}$$$ is the number of prefix $$$c_{j}=1$$$ and suffix $$$c_{j}=-1$$$,and it's equal to the total number of $$$c_{j}=-1$$$ plus a prefix sum of the sequence $$$c$$$.So we can use the segment tree to solve it.

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

Attention! Your solution 132999485 for the problem 1602C significantly coincides with solutions Scut22/132996768, phantom654/132999485. Such a Enr oxamole do not use ideone.com with the default settings (public access to yOur code). If you have conclusive evidence that a coincidence has occurred due to the use of a common source published before the competition, write a comment to post about minutes ago the round with all the details. More information can be found at http://codeforces.com/blog/entry/8790.Such violation of the rules may be the reason for blocking your may be blocked.

I agree the codes are very similar but the logic of the problem was pretty straightforward. Also using variable names like cnt for counting, g for gcd is a quite standard. So I appeal that it was a mere coincidence. Also Scutt22 seems to be from outside India, and I don't know him in any way. Also please note that I submitted the problem during first 30 minutes of the contest. @MikeMirzayanov