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

Привет, Codeforces!

В 29.01.2020 17:35 (Московское время) состоится Educational Codeforces Round 81 (рейтинговый для Див. 2).

Продолжается серия образовательных раундов в рамках инициативы Harbour.Space University! Подробности о сотрудничестве Harbour.Space University и Codeforces можно прочитать в посте.

Этот раунд будет рейтинговым для участников с рейтингом менее 2100. Соревнование будет проводиться по немного расширенным правилам ICPC. Штраф за каждую неверную посылку до посылки, являющейся полным решением, равен 10 минутам. После окончания раунда будет период времени длительностью в 12 часов, в течение которого вы можете попробовать взломать абсолютно любое решение (в том числе свое). Причем исходный код будет предоставлен не только для чтения, но и для копирования.

Вам будет предложено 6 задач на 2 часа. Мы надеемся, что вам они покажутся интересными.

Задачи вместе со мной придумывали и готовили Роман Roms Глазов, Адилбек adedalic Далабаев, Владимир vovuh Петров, Иван BledDest Андросов и Максим Neon Мещеряков. Также большое спасибо Михаилу MikeMirzayanov Мирзаянову за системы Polygon и Codeforces.

Удачи в раунде! Успешных решений!

Так же от наших друзей и партнёров из Harbour.Space есть сообщение для вас:

Hello Muscat

Привет Codeforces!

В качестве специального приза за Educational Round 81 мы разыграем бесплатные участия в Hello Muscat ICPC Programming Bootcamp, который состоится 19-25 марта (Оман) — полное покрытие оргвзноса, проживания и питания по системе «полупансион» на весь период учебного лагеря (но без перелёта). Путевки будут предложены топ-участникам, кто заполнил форму и соответствует условиям.

Условия:

  • Участие не менее чем в 10 рейтинговых раундах на Codeforces.
  • Максимальный рейтинг меньше 2400.
  • Еще имеете право принимать участие в ICPC и/или IOI.
Заполнить форму→

Всем удачи!

Мы также рады сообщить, что работаем с нашими партнерами над тем, чтобы обеспечить бесплатное участие (без перелёта) для команд, отправляющихся на финал ICPC. Если вы и ваша команда имеете право на участие в финале ICPC 2020, который будет проходить в Москве, заполните форму ниже, чтобы узнать, имеете ли вы право на бесплатное участие в "Hello Muscat ICPC Programming Bootcamp".

Подать заявку→

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

Место Участник Задач решено Штраф
1 nickluo 6 177
2 KrK 6 184
3 NoLongerRed 6 185
4 Anadi 6 200
5 neal 6 204

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

Место Участник Число взломов
1 GiantTornado 58
2 rachit_raj 51:-1
3 harshraj22 41:-5
4 Ahmad__ 35:-1
5 MissTolochin 33:-2
Было сделано 1096 успешных и 873 неудачных взломов.

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

Задача Участник Штраф
A antontrygubO_o 0:01
B neal 0:05
C IgorI 0:07
D NoLongerRed 0:06
E Egg_Tart_Forest 0:14
F Combi 0:23

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

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

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

Educational Rounds always have good problems. Hope for a good contest.

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

Finally a contest ! Hope the gap between rounds will decrease

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

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

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

2f04e47240ec34bbe32.png

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

Petition to MikeMirzayanov to decrease the gap between forthcoming contests.

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

7 days is a way too longer gap.

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

Looking forward to interesting problems

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

vovuh are you the Vladimir Petrov who won IMO Gold in 2018?

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

I hope the statements will be short.

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

Lets hope that the frequency of contests increases.

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

Problems are difficult!

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

B and C are difficult.

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

Even if the problem is not original, I think providing links to such problems and solutions during contest violates the CF round rules. Let us keep silence until the end of the round.

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

Finally solved the first problem. Heading for second. So much to learn...!!

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

I guess, someone accidentally swapped B and D :)

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

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

A Problem of APIO 2016:Boat

A harder version of problem F.

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

How to solve D?

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

How to solve E?

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

    keep segtree on array where arr[i]=cost if you split at i, start by putting everything on the right and leaving the left empty, so arr[0]=a[0], arr[1]=a[0]+a[1]... then start by putting 1 on the left, then 1 and 2, then 1,2 and 3 and so on. when you put a new number on the left the cost for all splits with that number already on the left decrease by a[position[i]], the cost of all the splits without that number (the ones with i<position[i]) increase by a[position[i]]. each time get the minimum in range (0,n-2) (because you can't split at last element).

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

    Another segment tree solution that doesn't require range update/lazy propagation:

    Represent each segment by the triple $$$(suml, sumr, cost)$$$. Define the combination of two segments as follows: $$$A + B = (suml_A + suml_B, sumr_A + sumr_B, \min(cost_A + suml_B, sumr_A + cost_B))$$$ (this operation is not commutative, but it is associative)

    Start with $$$tree[p_i] := (0, a_i, 0)$$$. Iterate $$$i$$$ over $$$[1, n-1]$$$ by updating $$$tree[p_i] := (a_i, 0, 0)$$$, then grabbing the $$$cost$$$ value from the "sum" of the entire segment tree. The answer is the minimum $$$cost$$$ value retrieved.

    Explanation: Fix a split of the permutation to sets $$$L$$$ and $$$R$$$. $$$suml$$$ represents the sum of the costs of $$$L$$$ in that segment, likewise $$$sumr$$$ for $$$R$$$. Now consider how to combine the statistics for segments $$$A$$$ and $$$B$$$. Combining the sums is obvious, but what is $$$cost$$$? Consider there is a point $$$x$$$ within the segments where we want to move all points $$$i \gt x$$$ from $$$L$$$ and $$$i \lt x$$$ from $$$R$$$. If $$$x$$$ is in the left segment ($$$A$$$), the new cost is $$$cost_A + suml_B$$$, as we must move all members of $$$L$$$ in the right segment ($$$B$$$). If $$$x$$$ is in $$$B$$$, the new cost is $$$sumr_A + cost_B$$$ as we must move all members of $$$R$$$ in $$$A$$$. We thus pick the minimum of these two scenarios. The updates progressively move elements from $$$R$$$ to $$$L$$$ as the initial split. Be sure not to move the last element, or your answer would always be spuriously $$$0$$$.

    Sample: 69829539

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

Am I stupid? How do you solve D? I got to count numbers $$$b$$$ with $$$0 \lt = b \lt m$$$ with $$$gcd(m, b) = gcd(m, a)$$$ but made zero progress afterwards

Edit: As I look at my previous claim I realize that my proof in-contest is flawed. Does anyone know if the statement is actually correct? Looking at the solution given, my statement should be true but I am unable to prove it.

Edit: Just kidding, not flawed. $$$gcd(a, b) = gcd(b $$$%$$$ a, a)$$$ which easily applies to $$$gcd(m, a+x) = gcd((a+x)$$$%$$$m, m)$$$ since $$$a+x$$$ takes on m consecutive unique values, we know it takes on every integer $$$[0, m)$$$ exactly once.

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

I'll bite, how to solve F? :P

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

GG, thanks for all the awesome problems! It was my first time participating in such a coding contest and it did take me some time to get used to many things on Codeforces. As a first-timer, Codeforces is like a gold mine to novice programmers like me xD.

Can someone give me a few pointers on how to improve as I found some questions quite challenging and there are always some nuts who can solve them in like 10min :D

Cheers~

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

How to solve C? My idea was to use hashmap (Key: Value being Char: List of Index) for characters of string S. But got TLE

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

It might be a very weird thing to ask as an author, but how to solve F?

It seems that my model solution is a lot more complicated that the ones from the participants.

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

Hi, can anybody make a hack? I receive an error after Hack button..

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

Did you really think this B was appropriate?

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

I just found a cheat in this contest;

At "Hacks" page of this contest. I found lov.ish and InsaneNerd hacked each other on problem B. Since it's very funny, I looked into their solution and only to discover they copied each other and the both get accepetd in their latest solotion!

By the way, lov.ish's code even didn't have indentation.

By the way, lov.ish used bad word as his handle. (lol)

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

How do I know if D Euler(m / gcd(a,m) )

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

    Instincts....

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

    Let $$$d = gcd(a, m)$$$.
    Since $$$0≤ x \lt m$$$ and $$$1 \lt = a \lt m$$$, we easily conclude that $$$(a + x)$$$ mod $$$m$$$ can take values in the range $$$[0, m - 1]$$$ and we know that $$$gcd(a + x, m) = gcd(m, (a+x)\ mod \ m) = d$$$

    Let's look at the case when $$$d = 1$$$, let $$$b = (a + x)\:mod\:m$$$, our goal is to find all the values of b where $$$gcd(m, b) = 1$$$ which is by definition $$$\phi(m)$$$ given that we concluded earlier that b can take any value in the range $$$[0, m - 1]$$$.

    Now, let's consider the case where $$$d \neq 1$$$. Clearly, the values of b that we are looking for in the range $$$[0, m - 1]$$$ must be multiples of $$$d$$$, so let's enumerate all the $$$m / d$$$ multiples of $$$d$$$ in this range as follows: $$$ 1, 2, ..., (m / d)$$$. Let $$$i$$$ be the enumeration of the $$$i^{th}$$$ multiple, we want to count $$$i$$$ such that $$$gcd(i * d, m) = d$$$, but since $$$d \ | \ m \ and \ d \ | \ (i * d)$$$, we really want to count $$$i$$$ such that $$$gcd(i, m / d) = 1$$$, which turns out to be $$$\phi(m / d)$$$.

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

Problem is saying 998244353 decimal digits. What i was thinking number should be less than 998244353. Can anyone suggest what should i do to avoid such type of mistakes ???

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

Such a bug B!This round shoule be unr!

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

how to solve B?

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

    You can create an array $$$cnt_0$$$ and $$$cnt_1$$$ in which $$$cnt_x[i]$$$ is the number of characters $$$x$$$ are from $$$0$$$ to $$$i$$$. Also, you can calculate $$$delta[i]$$$ which is $$$cnt_0[i] - cnt_1[i]$$$. Then, when the string is repeated again, the same pattern of $$$delta$$$ is going to occur but increased by a constant, because the number of $$$0$$$ and $$$1$$$ that you have from the previous string are accumulated. I'm going to concatenate $$$s$$$ two times to make the pattern visible.
    Let's analyze the following input
    $$$n = 6, x = 10, s = 010010$$$
    $$$cnt_0: 1, 1, 2, 3, 3, 4 | 5, 5, 6, 7, 7, 8$$$
    $$$cnt_1: 0, 1, 1, 1, 2, 2 | 2, 3, 3, 3, 4, 4$$$
    $$$delta: 1, 0, 1, 2, 1, 2 | 3, 2, 3, 4, 3, 4$$$
    Every time a string has finished, delta is going to change in a constant. Let's called that constant $$$d = delta[n] - delta[0]$$$. For each position $$$i$$$ between $$$0$$$ and $$$n - 1$$$, you know that you can reach all the numbers of the form $$$delta[i] + kd$$$, in which $$$k \geq 0$$$ because it is the number of times that the string is going to be repeated. So, for each $$$delta[i]$$$, $$$i$$$ between $$$0$$$ and $$$n - 1$$$, you have to check if it possible to obtain a non negative $$$k$$$ such that $$$x = delta[i] + kd$$$. The only corner cases are in which $$$d = 0$$$, then, if you have at least one solution, you are going to have infinite solutions of this form. Finally, check the case of the empty string if the solution is no infinity. The time complexity is $$$O(n)$$$.

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

    take '0' as $$$1$$$ and '1' as $$$-1$$$ and calculate the prefix sum $$$pre$$$.

    then for each $$$pre_i + x\cdot pre_n = balance$$$_$$$value$$$, if there is a non-negative integer $$$x$$$ satisfying the formula, add 1 to the answer. if balance_value is zero then add another 1 to the answer.

    if $$$pre_n=0$$$ then if there exists an $$$pre_i=balance$$$_$$$value$$$, then answer is -1; else answer is 0.

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

VERY VERY WEAK test cases for B :(

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

Author is fond of strings i guess.

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

D can also be solved with mobius function(Inc-Exc) 69790210. Let g = gcd(a,m). gcd(a+x,m) is g if and only if g|x. gcd(a+x,m) = gcd(g*c1 + g*y, g*c2) = g. gcd(c1 + y, c2) = 1. Use inc-exc now — neglect non-square free numbers for others if a divisor is prime product for even number of primes than subtract such numbers, for odd add them using the observation that if mu[n] = mu[d]*mu[n/d].

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

Anybody with a good hack for B?

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

How to solve C ?

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

I am not sure about my solution, can anybody hack my solution.

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

I am not sure about my solution,can anybody hack it.

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

that was one of the worst contest in all of the codeforces rounds. the problems were really bad. i hope to see better contest in future.

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

Can someone explain the idea "phi value of m/(gcd(a,m))" for problem D? I mean how we got it?

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

will there be points for successful hacking during the hacking phase?

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

69796073

Is it possible to see the hack case for my solution after preliminary result? I really have no idea of the counter example :(

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

I solved E without any range updation datastructure , just use map of values which have arrived and changes the current cost with coming elements and decrementing the cost if already added to the initial cost, it gives me wrong answer on testcase 10, can anybody look into it my submission https://mirror.codeforces.com/contest/1295/submission/69796456

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

Can anyone please tell me what is wrong with my code for problem B. https://mirror.codeforces.com/contest/1295/submission/69788305

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

A was very similar to 101612A - Auxiliary Project

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

What is "Unexpected verdict"? Hack #613188

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

Didn't know much about such a nice function (Euler Totient Function)

Thanx to problem D for increasing my knowledge.

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

I think so many TLE codes are "accepted" in Problem C.

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

Editorial please?

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

Am I the only 8ne who solved C with a precomputed DP

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

When will the system testing start?

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

where's the rating Lebowski

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

For question B: Can anyone explain why the output of

1
3 0
011

is 2 ? Please help, my solution is hacked and I don't know why

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

No matter how hard I try, I could not understand the solutions given for problem D. It would be great if someone could explain me how to do in simple and detailed steps. I would be really grateful to them.

Thank you!

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

when will editorial be published?

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

Has the editorial for this contest been published yet? Or there won't be one?

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

expert in a one contest

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

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

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

problem A What's wrong in this?

include<bits/stdc++.h>

using namespace std; long long n; int main(){ int t; cin>>t; while(t--){ cin>>n; if(n%2==0){ for(int i=0; i<(n/2); i++) cout<<"1"; } else{ cout<<"7"; if(n!=3){ for(int i=0; i<((n-1)/2); i++) cout<<"1"; }

}

cout<<endl; }

}

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

love the problems,short and easy to understand

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

Why is this solution so slow? (Problem C):

http://mirror.codeforces.com/contest/1295/submission/70937323

As for me, the complexity of this one is O(T*|t|*log(|s|))