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

Привет, Codeforces!

В Oct/25/2018 17:35 (Moscow time) состоится Educational Codeforces Round 53 (Rated for Div. 2).

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

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

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

Задачи вместе со мной придумывали и готовили Роман Roms Глазов, Адилбек adedalic Далабаев, Владимир vovuh Петров и Иван BledDest Андросов.

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

А вот сообщение от наших друзей из Harbour.Space:

Hey Codeforces! We want to remind you that the Scholarship for the Master’s in Robotics programme, which starts on January 7th 2019, has an application deadline of November 12th, 2018.

Harbour.Space University and Remy Robotics are collaborating to offer graduate students from anywhere in the world a once in a lifetime opportunity, a fully funded scholarship for Harbour.Space University’s Master’s Programme in Robotics.

The scholarship value is €34.900 and it includes:

  • Complete coverage of the University tuition fee (€22,900)

  • Internship at Remy Robotics (20h per week during 1 year)

  • €1,000 per month during 1 year (Internship earnings)

Apply here

UPD: Мы с vovuh будем ждать всех желающих в местном Discord сервере сразу после контеста для обсуждения задач.

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

Место Участник Задач решено Штраф
1 pekempey 7 305
2 ko_osaga 7 578
3 Lewin 6 216
4 fanache99 6 226
5 natsugiri 6 257

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

Место Участник Число взломов
1 halyavin 238:-15
2 Laggy 64:-14
3 MarcosK 59:-9
4 Mistra 8:-1
5 LordVoldebug 7:-1
Было сделано 482 успешных и 684 неудачных взломов.

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

Задача Участник Штраф
A Dalgerok 0:01
B dorijanlendvaj 0:02
C fanache99 0:10
D bazsi700 0:13
E DAyamaCTF 0:21
F Noam527 0:48
G ko_osaga 0:24

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

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

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

...

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

I always have this question:Why Educational Codeforces Round uses extented ACM ICPC rules? I think the rules of CF regular rounds are very good:-) Thank MikeMirzayanov

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

I'm sorry. The last comment was not posted by me. I'm not mean to do it.

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

Good luck to all

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

Hi all! this is my first round here. what should i know about codeforces?

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

An Educational round after a bad contest, awesome.

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

Educational Round is here, Summon halyavin !!

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

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

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

Чет у меня не пошло, жду тестов)

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

How to solve Problem C?

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

I'm so sad that I didn't have a code ready for segment tree beats. This would have been the first time I could use it in a real contest (in problem G) :(

Didn't have time to write it either since It once again took me too long to read other problems after getting stuck in one.

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

    I dont think G needs segment tree beats though it is nice if it can solved that way.

    we can compute lcp array and then for each query we can keep 2*query size ranges and perform something like for how many pairs of a and b will particular range be minimum value (its similar to solving sum of minimum over all segments in an array but instead we have weights to elements here).

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

How to solve E?

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

    In general — digits and masks DP. Calculate the following dynamic programming: dp[pos][mask][f], where pos is the current digit of a number (starting from the greater one), mask is the binary mask of used digits and f equals one if prefix of our current number is the same as in the number n. You can calculate the sum of suitable numbers from 1 to n using this DP. Then the answer is calc(r) - calc(l - 1).

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

      I have a confusion. A prefix can be in the range of 64-bit integer. How can I use this big number as a state?

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

        You don't need to use the number as a state. The position in this number is enough. To do some transactions you need to place the new digit in your number and recalculate DP. Ohh, the most important thing — to calculate the sum of numbers you need to calculate two DPs, one for the count of such numbers (this DP is auxiliary) and DP for the sum of such numbers (to calculate the answer).

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

          Hey, why don't you need to keep track of if you have put something greater than 0, for cases like 000124 and k = 3, because you only turn on the 0-th bit if you had put something greater than zero before?

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

            My solution calculates this DP independently for each length from 1 to |n| and says the sum of numbers of exactly such length. But I thought that I can calculate for all lengths at once because where you places leading zeroes, the count of these numbers will be right. The sum will be right also (because 0 doesn't contributes to the sum at all)

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

      Sorry, I read that wrong.

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

      I can find number of different integer from [l,r] using digit-dp but how to find sum of these integers?

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

        say calculate for num = 78520193
        iterate from left to right, say you are at position 3 (digit -  > 5) right now, then how many times (say T) does 500000 in your answer?
        it is simply number of ways you can form numbers  <  = 520193 which can found by DigitDP ( you also need to ignore if number of digits used are > k , for which you can use mask --> set the bit for the digit you included ) then this sum would be 500000 * T.
        Now this value if repeated for 78520193, 68520193, 77520193... and so on , since prefix upto position 2 can also change , so for that make another dp table and do the same digitDP for this now.

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

    Probably DIGIT DP, however could not implement it ;(

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

    I always try to make something recursive like answer(A, i) that is filling array A from 17 to 0 and i is the position where we can choose a value. Complexity would be 10^18, but if we make these optimizations complexity drops: If the number cannot be in the range [l,r] return 0; if it will always be in a range [l, r] ask the answer from another dp function.

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

Какой седьмой тест в B?

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

the contest ended ?? it was scheduled to start now, did i miss something ?

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

I am having a hard time with Problem B, Please Help.

My code which works on every other online IDE under 0.01s is getting TLE on case 1 here. I have used GNU's policy based ordered tree in it. used G++ 17 to submit.

Here is my submission -- > 44858365

I tried tweaking things a bit, using int instead of ll. Nothing helped. This thing ruined my already not so good rank, had to rewrite a different solution. :(

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

how to solve D?

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

I tried to use two pointer technique for problem C.

Code

However I got a WA. Can somebody please help me in figuring out where I was wrong.

Idea:- Caluclate the position x and y based on the given string. Calculate the diff in x and y based on goal x and y. Now calculate diff between goal x and x and for goal y and y. Now if the diffs in each dimension are not divisible by 2 or the required characters needed are less than given in the string output -1. Otherwise use two pointer to find the shortest string length.

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

I feel like D was much easier than C. Some people wasted too much time unsuccessfully solving C, while they could solve D instead.

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

Dear anyone please try to hack my solution for D 44864411 Thanks :D

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

How to solve C ?

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

    Binary Search for the answer. To check whether you can have a subsegment of length x as the answer iterate over all the subarrays of length x and then all you have to check is whether the difference between the expected position and the actual position is greater than the subarray length or not and also if the difference is less than the subarray length we need to check the parity of the difference between the 2 values.

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

in problem C, when I realized that I used binary search in wrong way, and it took a lot of time to correct my solution but too late. Im now feel a little regret about it, hmm. Hope these experiences will help me grow up in the future. Hope you guys have good rating after the contest <3<3<3

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

can anyone give me a single reason why this solution give tle https://mirror.codeforces.com/contest/1073/submission/44874378 and when i change compiler to c++11 it give acc + almost all my friend list got acc with the same code and without fast input and this is my code acc https://mirror.codeforces.com/contest/1073/submission/44877617

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

Правильно ли использовать два указателя в задаче С? Решение прошло претесты.

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

How do you solve D? I thought of using 2 BITs, however the number of submissions indicates an alternate easier solution.

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

Can someone please tell me how this O(n) solution TLEd on B? http://mirror.codeforces.com/contest/1073/submission/44854424

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

i can't hack with Generator and i get invalid input can you help me

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

    There can be two reasons for invalid input. 1. Make sure you have newline character at the end of the generator output. 2. Make sure the last integer or character or whatever variable of generator output is followed by new line character instead of a space i.e. run loop for n-1 numbers and print last number followed by new line character instead of space followed by newline character

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

Can anyone explain C in detail. What are we exactly doing after applying binary search on the length of a substring?

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

    In C, we can see that if we do change a substring of size k, then it doesn't matter if we change 1 or k elements in the substring. An easier approach would be to change all of them.

    Let's say that we're at (x, y) and we have to go to (a, b). The shortest way between the two points is the Manhattan distance between them. However, if your k is greater than this Manhattan distance, you might want to 'waste' some moves before you reach there. It is easy to see that the number of moves you 'waste' will always be even.

    So, if we do have to change this k subsegment, we can do it only if we can travel the Manhattan distance, and waste some moves if any. More formally, you get k >  = dist((a, b) , (x, y)) and (k)mod2 = (dist)mod2.

    Another observation is that if you get a valid subsegment of size k, you can get it for k + 2 as well. However, we don't know about k - 2.

    So, we would binary search over all the even sizes and odd sizes of k separately and pick the minimum. We can binary search as the function of whether k works or not is monotonic. Or in other words, it's of the form NN...NYY..Y.

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

      can you please elaborate why binary search works here. i didn't get the last part.

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

        The reason we can apply binary search on a sorted array is because of the property that if i > j =  > A[i] >  = A[j]. So, if we are searching for an element k, and it's lesser than the present index, it implies that it would be lesser than all the indices on the right, so we don't need to check there.

        Similarly here, we can observe a similar property, which is that if we can find a suitable segment of size k, we can find it for all k + 2 * c, where c >  = 0. Thus, we could check for a potential minimum on the left. This is because the number of moves we 'waste', will always be even.

        On the other hand, if k it not suitable, it means that all k - 2 * c for all k / 2 >  = c >  = 0 will not be suitable, and thus we need to check on the right.

        You could have a look at the Topcoder tutorial here for a better explanation.

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

Can someone explain it to me why the solution for E got WA on 7? My solution for E I know my solution will calculate wrongly in some big cases but I don't know why.I take mod everywhere. Sorry for my poor english. :)

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

Can any moderators look into this case? Thanks!

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

What are the hack cases on C?

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

What does this error mean?

How to correct the error?


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

A very very nice observation in D of why brute force would pass: The outer loop won't execute more than log(t) times because after each loop, t becomes t%i where i is some number <= t and if i<=t, t%i can take values from 0 to t/2 (proof is easy :) )

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

Can anyone explain why this gave TLE for problem D: https://mirror.codeforces.com/contest/1073/submission/44873511

The complexity according to me is O(n * (log n)^2) which should have passed. Is it because of inefficient code?

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

What's special in test case 8 for F problem.Getting "Sum of paths in jury is larger than participant".Isn't it just the two farthest nodes from the respective 2 end nodes of the common vertices path?

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

How to solve F?

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

I'm very sorry of what I've said

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

Editorial?

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

Why is E easier than D and D is easier than C -_-

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

Can any one provide me with nice digit on dp blogs?

Thanks in advance

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

Why E Wa on test8? I'm very confused.

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

Is the editorials published?

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

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

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

The solution of problem F is: use greedy thoughts to find the longest path in the tree. So, we will look for the first point of the common part as root, then dfs () from that root to find the other end

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

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

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

Can anybody describe the solution of the problem G (Yet another LCP problem)?

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

Has editorials been published? If not, can anyone provide me solution to Problem D.