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

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

Добрый всем день! Этот раунд будет немного особенным, потому что он составлен из задач школьного этапа всероссийской олимпиады школьников по информатике в городе Саратов. Задачи для вас придумывали и готовили Александр fcspartakm Фролов, Иван BledDest Андросов и я, Владимир vovuh Петров. Удачи всем!

UPD: Спасибо Дарье nooinenoojno Степановой и Данилу sad101010 Смирнову за тестирование!

UPD2: Мы откроем решения для просмотра и начнем фазу взломов чуть позже, потому что школьный этап олимпиады еще не закончился. Мы откроем все примерно через два часа. Пожалуйста, не обсуждайте решения задач в течение следующих двух часов.

UPD3: Теперь вы можете обсуждать задачи.

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

<almost-copy-pasted-part>

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

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

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

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

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

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

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

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

Удачи!

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

</almost-copy-pasted-part>

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

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

Is it rated for all problem XD

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

funny

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

Excited for my first contest :)

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

Too early

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

Я, конечно, дико извиняюсь, но как ваша Div3B задача в плане претестов? Ммм?

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

I hope the problems are sorted by difficulty:)

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

How and when can I hack others solutions? Morning I was searching for that option in educational codeforces. Didn't get it. So someone give detailed description of how to see and hack others code please.

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

I missread it as "Thanks to Smirnoff for tasting!".

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

So if you rating is more than 1600 then you will be unofficial.
Otherwise, you must be a trusted participant to be in the official table. However, even if you are not a trusted participant and have ratting less than 1600 then the round will be rated for you.
I did not get it. Can a participant not be in the official table but his/her rating changes?
Or there is an official table separated from CF?

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

    Basically when you switch from unofficial to official standings, in addition to removing non-div3 participants, it will remove all non-trusted participants. However non-trusted participants will still be used for rating calculations. So to simply answer your question — Yes, it will be rated for them but they will only be visible under unofficial standings

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

I hope I will start with Expert on CodeForces.

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

hoping to gain rating!

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

Finally Div-3... Want more contest of Div-3.. In fact one in every week....

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

Бахните потом div2 по муниципальному

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

wonderful

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

Where is Zoro ? :D :D hahaha

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

Another contest as i have lessons (not computer) in the school... That's terrible...

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

Damn I just woke up

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

A similar problem. Similar to problem E.But I am still unable to solve E2

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

Why is sum of area of intersection = area of original rectangle not working in C :((

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

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

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

In D, I have taken the difference of every element with the maximum element of the array. Then took the gcd of all the values which is the minimum number of swords each person will take. Then the answer will be the number of persons and swords each person will take.

Why I got the WA in test case 5?

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

Dat feel when you start from C...

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

No hacking phase ?

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

How to solve F?

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

Odd, is there no system tests? Usually the standings say "System testing" but now it just says "Final standings".

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

Какие из задач были на школьном этапе? Не верится в то, что на нем была E.

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

    Все эти задачи были на школьном этапе. Мы не включили в Div. 3 только самую простую задачу из набора.

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

      Эх, нам бы такой школьный этап в Смоленске! Будем, как обычно, решать пять баянистых задач, после чего их вручную проверят тестами с бумажки (что делает ограничения абсолютно бесполезными в половине случаев, но никого это не волнует).

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

        Поверьте, в Саратове все тоже не так и гладко, как кажется на первый взгляд :)

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

        А как вам задача: Дана строка длины n (1 <= n <= 10), нужно найти любую её подстроку, являющийся палиндромом.

        Не смейтесь, это 3-я (!) задача, из 5, школьного этапа!)

        Кстати, 5-я реально интересная, но первые 4 решаются за 3-5 минут каждая от силы.

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

      8 задач на 2 часа?

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

      Лол, я хоть и не решал, но было интересно на задачи смотреть. А у нас в Питере в школьном этапе вообще нет ни намёка ни на ДП, ни на какие-то техники — первые 4 задачи зелёного уровня на Codeforces и 5-я задача голубого. А потом такой скачок сложности на регионе)

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

How to solve E?

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

problem E1 wrong test 1??? :(

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

Is F was lazy propagation

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

Not able to understand D at all. To much words and entities.

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

Come on, guys, stop discussing problems, please. The elimination stage in Saratov is still not over.

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

It was good contest. Thank you for all. btw, How long do we have to wait to be able to submit code?

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

Wouldn't it be more logical to start Div. 3 two hours before the end of the elimination stage, so that everyone would finish at the same time?

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

Late for 1 minute. T_T
Wait to submit my E2's code and hope that I will succeed.

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

How to solve C? I tried so hard and got WA on test 11 :( It's really disappointing. After so much hard work couldn't get the AC.

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

When hacks will be available?

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

why this output is wrong in problem B test 3

69 1 4 2 5 6 3

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

      Okay, if you need an explanation, here it is:

      Your permutation is $$$[1, 4, 2, 5, 6, 3]$$$. So durabilities of cans in order you will knock them down are $$$[5, 4, 4, 4, 5, 5]$$$.

      So the answer by the formula is $$$(5 * 0 + 1) + (4 * 1 + 1) + (4 * 2 + 1) + (4 * 3 + 1) + (5 * 4 + 1)$$$ $$$+ (5 * 5 + 1) = 1 + 5 + 9 + 13 + 21 + 26 = 75$$$. $$$75 \gt 69$$$ so firstly you're printed wrong answer and secondly it's greater than author's answer.

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

How to solve E2 ?

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

    I did it using binary search. for each i we are writing numbers from 1 to i. So first I did a binary search on i such that when I write from 1 to i+1, the number of digits exceed k. Now we have to find the number j between 1 and i+1 such that writing till jth number makes the number of digits greater than k. again binary search on this. Once we get j we can easily get our answer. you can refer to my code here

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

    Write down each block in a column and consider all the blocks that the last number has the same number of digits as the Big-block.

    // Big-block 1
    1
    12
    ...
    123456789           // the longest block in Big-block 1
    
    // Big-block 2
    1...910
    ...
    1...910...99        // the longest block in Big-block 2
    
    // ...              // ...
    

    The number of Big-blocks is about 9, so we can find k in which Big-block easily.

    Then the right block can be found by using binary search. I preprocessed the longest length of block in each Big-block and the sum of digits of all Big-blocks.

    Now this problem 1216E2 - Numerical Sequence (hard version) was translated to 1177B - Digits Sequence (Hard Edition).

    Here is my solution 61007196 and wish it can help you more.

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

when can i solve it again

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

Подскажите, пожалуйста, почему для B данный ответ не является верным?:

in:
6
5 4 5 4 4 5

out:
69
1 4 2 5 6 3

Правильная ли логика? :

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

For C, can someone explain how the answer is "NO" for TC 11:

50 100 100000 99000

13 4654 999999 1000000

0 0 1000000 45654

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

    Dunno why you ask. White rectangle is almost inside first black rectangle except a little part near point (0;0) and the 2nd rectangle covers this part.

    Possibly you should notice that it's 999999 that is not 99999

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

How to solve problem F?

I think it can be done using dp and segment tree with lazy propagation but am a little bit confused.

what should the dp state be and how to use segment tree efficiently with dp?

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

    Think of the problem like this — there are $$$n$$$ offers for intervals $$$[l_i, r_i]$$$ and the $$$i$$$-th offer has cost $$$c_i$$$ (this problem is only a special case). We want to cover all indices $$$1$$$ to $$$n$$$ and choose the cheapest such set of intervals.

    Now here's the dp state: let $$$dp[i]$$$ denote the minimum cost to cover indices $$$1$$$ to $$$i$$$ with intervals that have their right point $$$\le i$$$. The answer is $$$dp[n]$$$. The base is $$$dp[0] = 0$$$. How do you transition?

    To find $$$dp[i]$$$, you must cover indices $$$1, \cdots, i - 1, i$$$. Since in $$$dp[i]$$$ we're looking only at intervals that end $$$\le i$$$, obviously, we must choose at least one interval that ends at index $$$i$$$ to cover it. Also, we choose exactly one such interval, because if we chose more than one, we can pick the longest and that won't affect the answer. Which interval should we choose? Let's iterate on all possible choices for that — let's pick an interval that ends at $$$i$$$ (call it $$$[l, i]$$$) and say it has cost $$$c$$$. Once we have picked this interval, we just have to ensure that indices $$$1, \cdots, l - 1$$$ are covered because this interval covers the indices after $$$l - 1$$$. What is the minimum cost of this subproblem? It's not $$$dp[l - 1]$$$, because there could be a cheaper configuration with intervals that end after $$$l - 1$$$ but before $$$i$$$. To cover those possibilities, we take the minimum of $$$dp[l - 1], dp[l], \cdots, dp[i - 1]$$$ (call it $$$m$$$). So the optimal cost of doing this is $$$m + c$$$. And $$$dp[i]$$$ is the minimum of this expression over all intervals that end at $$$i$$$.

    We can store at each index a list of intervals that end at that index, and to support finding $$$m$$$ quickly, we can maintain a segment tree that stores $$$dp$$$ values of each index and allows us to find minimum in a range of indices.

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

Can any one tell why my solution got failed on test1 61010239

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

deleted :)

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

I wrote a segment tree to solve problem F, and I also know that it can be solved with something like the sliding-window. But I found many solved it without using any data structures example. I'm just wondering how that works.

Can someone please help me with that?

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

How to approach E1?

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

    Process the number of digits of i and get the prefix sum, then use a binary search to find i which takes up the k-th posithon. Finaly the answer is the k-sum[i-1]-th digit of i.

    Here is the commit which is my solution for E2. If you are interested in E2, Link it.

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

Is E2 Digit DP?

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

RIP my problem E :<

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

What's the hack for C?

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

Submitted a solution for problem D with complexity n*log(10^14) + sqrt( 10^14 ) This gave a TLE in java in test case 16 during contest Same code I rewrote in c++ after contest. It passed all pretests.

Time limits too strict for Java

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

It was interesting that my exact the same solution for A was TLE in PyPy3 but accepted in Python 3. Any idea?

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

    Try to avoid using += with strings in Python, when you add chars multiple times. There are some optimizations thrown in here and there, but it sometimes happens that this method's performance degrades to $$$O(n^2)$$$, since each time you append a couple of chars this way, a brand new copy of the whole string may be created.

    Instead, you can put all strings into an array, and then write something like s = ''.join(a), which is definitely faster.

    Update: now your code passes in 140 ms — 61033581

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

Same solution, just change in indentation and variable names, was expecting same handle too! :(
sol1: 60988370 sol2: 60998975

MikeMirzayanov sir, please look into the matter.

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

Hi MikeMirzayanov, I had used unintentionally public online compiler(ideone.com) in middle of contest for solving Question D. Here is link to my solution on ideone which I had used in middle of round unintentionally. But there is message from system saying that my submission is exactly same with some other guy. Here is his solution which is exactly same as mine. I think he has taken the solution from there only because I don't know that guy. It is my mistake to use online public compiler which I will take in account for further codeforces round.

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

i think my solution 60995513 for the problem 1216F and solution 60994761 of tuan52 just a coincidence, Because each problem can have different ways, the same idea is inevitable. tuan52 and I use queues so we can have the same idea, can't say we copy each other's code

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

This is regarding the notification I received having similar code to some other codeforces user. For problem B, the code to keep track of indices is available here https://www.geeksforgeeks.org/keep-track-of-previous-indexes-after-sorting-a-vector-in-c-stl/ and the rest logic is highly vulnerable to probability of being same.

Also I did use ideone on public setting unintentionally http://ideone.com/KvSYMv but thought this is highly unlikely to be copied since almost 100+ submissions are done every minute there.

Anyhow,the system may realize, I have clear early submission & please remove the warning on my profile.

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

I received a talk from System saying that my solution 60971083 for the problem 1216A significantly coincides with solutions Arianfk/60969857. It's just a coincidence. I am surprised that the two solutions are almost the same. I wrote the code myself without reference to any third party code. 1216A is a simple problem that can be solved with only a few lines of code, and I think it is true that the similar solutions may occur.

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

This is regarding the following system message I received.
Attention!
Your solution 60996009 for the problem 1216C significantly coincides with solutions meet29/60996009, gagan_6730/60997664. Such a coincidence is a clear rules violation...

Upon investigating (if it can be called that), I found that it's the exact same solution. The only thing is that my submission was made earlier. I could think of no reason how my code could have been leaked as I never use any online IDE, just editors, and compilers on my machine. But, later, I recalled that I had received a new sign-in mail while the contest was running. I had thought at the time that it was probably a delayed mail for my own sign-in (OS and browser were the same) so I didn't think twice about it. Now, that is the only thing that makes sense to me. I don't know for sure if that is what happened i.e. my account was compromised, but that is the only logical explanation to me. The IP did turn out to be different.
The timeline of events was as follows — I submitted, then I received the mail about a new sign-in, and then the copied solution was submitted.
I don't know if this would constitute as an unintentional leak, but if it would, I take responsibility for any penalties. Regardless, I have taken the necessary steps to secure my account so that such an instance does not repeat (if this is what had happened). Will surely be more careful from now on. Lesson learned, the hard way.

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

Clarification of my flagged plagiarism submission:

Your solution 60992562 for the problem 1216C significantly coincides with solutions anonymous-420/60989907, CandyZack/60992562.

I have used a part of the code from stackoverflow, the link is below. https://stackoverflow.com/questions/27152904/calculate-overlapped-area-between-two-rectangles

Because both the submission uses the same code form external site, I urge you to remove the plagiarism on my submission.