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

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

Всем привет!

Завтра состоится всероссийская олимпиада школьников для 5-8 классов имени Келдыша. Удачи всем участникам! Олимпиада проходит под чутким руководством московской методической комиссии в лице GlebsHP, ch_egor, Endagorion, vintage_Vlad_Makeev, Zlobober, meshanya, cdkrot и, конечно, Андреевой Елены Владимировны.

Мы рады представить раунд codeforces на основе задач олимпиады. Это будет Div. 2 раунд, который состоится в 16.06.2019 12:35 (Московское время). Возможно, вы уже и раньше участвовали в раундах на основе олимпиад, подготовленных московской методической коммисией (раунды 327, 342, 345, 376, 401, 433, 441, 466, 469, 507, 516, 541, 545)

Задачи этой олимпиады были подготовлены voidmax, alexey_kuldoshin, ch_egor, budalnik, achulkov2, manoprenko, vintage_Vlad_Makeev, Endagorion.

Также спасибо KAN за помощь с организацией Codeforces версии соревнования и MikeMirzayanov за системы Codeforces и Polygon.

Также хотелось бы поблагодарить компанию Tinkoff и лично Татьяну Колинкову за организацию онсайт соревнования.

Желаю удачи!

Разбаловка: 500-1000-1500-1750-(2000+750)

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

Div. 2:

  1. thecodinglizard
  2. baIuteshih
  3. Cong1500DanPaiXia0
  4. Yelan
  5. HatsuneMikuo

неоффициальный Div. 1:

  1. Radewoosh
  2. isaf27
  3. chemthan
  4. uwi
  5. kmjp

Разбор будет скоро опубликован.

upd. Опубликован разбор.

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

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

Наконец-то смогу показать этим пятиклашкам, кто здесь главный!11!!

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

    До тура: Ща покажу, кто тут главный!!!

    После: Почему у меня меньше, чем у пятиклашек???

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

      Могу с уверенностью сказать, что и сейчас меньше, чем у пятиклашек.
      UPD: Ч.Т.Д...

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

        Надеюсь вы про количество решенных задач , а то у меня фантазия заигралась.

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

Если это действительно Div.2, то не завидую 5-6 классам. Удачи вам!

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

    Главным образом олимпиада ориентирована на 8й класс, но мы рады видеть и более младших школьников :)

    А ещё школьникам чуть проще чем вам, потому что у них есть возможность сдавать решения на частичные баллы.

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

      А ещё школьникам чуть проще чем вам, потому что у них есть возможность сдавать решения на частичные баллы.

      А, кстати, зачем это так? Меня зимой школьник шокировал рассказом, как получил за явную лажу более половины баллов, потому что, с его слов, баллы соответствуют доле тестов, которые проходит программа. Я сейчас смотрю условие этой самой задачи 2 — там вроде как расписаны какие-то разумного вида подзадачи (k≤1000, k≤10⁵…), но речь была о программе, неверной для самых разных k, начиная с 12.

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

An unusual start time!!! Hope it give me an unusual experience .

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

An unusual start time!!! Hope it give me an unusual experience .

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

я могу написать этот раунд, если я участвую на олимпиаде Келдыша?)

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

    Разумеется, нет :)

    Раунд не случайно с ней пересекается.

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

Ind vs Pak CWC 2019 at 3 pm IST . Hard choice for Indian Cricket Fans to participate in this round.

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

    for dislikers: soccer world cup final attracted 1.6 billion viewers while today's India vs Pak crikcet match expected to attract 1.5 billion viewers..so dislikers do respect other's choices as well.. although i will be going for the contest :P

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

is it rated for everyone?

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

Who is Keldysh?

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

The time is very very very friendly to Chinese

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

    So What? It is equal to say, "Although the time is not friendly for many other people, but the time is friendly for Chinese." Doesn't it?

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

Clashes with India Vs Pakistan :-/

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

..для 5-8 классов..

Как жаль, что я 9-классник с интеллектом 4-классника ._.

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

Glad to see vintage_Vlad_Makeev and vintage_Vlad_Makeev working together

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

Another round I will miss because of university exams :(

These stupid exams came when I am that close of becoming master, My rating in 2080 :(

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

please How many problems were prepared

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

May I know how many problems are there and if the solution will be pubished?

Sorry for my poor English :) Thanks

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

Minor clarification, I'm new around here. Does All-Russian mean the questions will be in Russian only?

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

what is the score distribution??

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

Is it a rated contest?

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

I just hope it won't be a mathforces

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

Сколько задач будет на раунде?

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

Can you let me know how many problems are there and what the score distribution is?

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

hoping for specialist. prey for me.

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

Codeforces round vs India-Pakistan WorldCup match.Let's see what Indians prefer.

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

How does hacking work when there are two (easy and hard) versions of the same problem? They have to be connected somehow because somebody would be able to solve easy with brute force, lock it and check codes to find some which work even for hard version (and learn how to solve it).

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

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

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

How to solve C ?

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

    I found every 1 column flag and found out how wide they could become.
    for every such flag, we get width*(width+1)/2 different possible flags.
    Yes, |: 10^9 operations but it passed

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

      You can sort the list of 1 column flags in such a way that corresponding flags end up next to each other (sorting by row and column). Then it is easy to check how far they extend horizontally. This was quick enough that even my python solution got accepted (without 10^9 operations).

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

      Hey, can you please help me with my code. I got a TLE by using brute force (10^9 operations).

      My code: https://ideone.com/iDkAwr

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

        10^9 is already a lot. Using a map on top of that isn't helping.
        Instead of using the map, I simply edited the map and zeroed out the positions that were already calculated and it barely passed.

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

Hard, but interesting. Thanks!)

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

So hard.55555~~~

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

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

So hard, feel like I am a retard

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

"nice but hard to implement" problems !!!!

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

How to solve D?

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

hard problem for B

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

Where does my solution for problem C go wrong: code

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

let me summarize. B = C, C = D. right?

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

    And D = B.

    I really think it feels right like that

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

      was that really? Why I didn't try that!

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

        Yeah I just read it and I think it was! It was a huge mistake not to start with it after A.

        Might take some coding but no edge cases like in B & C.

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

          I found too much edge cases in C that I suddenly forgot what my idea was. And now, I got the idea unfortunately.

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

        Euclid's first axiom : if A=B and B=C, A=C.

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

Light-speed system test, I love it! WOW!

Upd. It only used about 20 minutes! REALLY COOL!

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

I wrote an O(nlogm+mlogm+qlogm) solution to problem D by merging some segment trees link. I thought that would pass under a TL of 2.5s for n,m,q<=5e5. However, it got a TLE. I tried all methods I know to make it run faster but it always gets TLE on pretest 10 or 11. I'm just wondering why a nlogn solution gets TLE. Is the constant of my code too big or a solution with a better complexity(O(n) maybe?) exists?

Sorry for my poor English.

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

    I saw some AC submitions with search in the BIT, maybe it helps you ^^

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

    I used a Fenwick tree to get the n-th city, and it has passsed. https://codeforces.com/contest/1181/submission/55639812

    There is no need to merge many Fenwick trees. Just maintain a simple sum-based seg tree.

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

      Thanks, I've discussed that with my friends and they told me about the solution with BIT. I think maybe the constant of segment trees is too big.

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

        I solved it with segment tree, check my code.

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

          I used ordered set from pb_ds to solve k-th ordered statistics problem, check out my submission: https://codeforces.com/contest/1181/submission/55642500

          Btw it's quite useful data structure, it can replace segment trees sometimes!

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

            Can you explain your solution? I was also trying it with policy data structures

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

              Well, let's do the following: let's maintain ordered set $$$d$$$ that represents all cities with the smallest number of hosting days. If the current year is $$$timer$$$, then in the next $$$d.size()$$$ years these $$$d.size()$$$ cities wiil be selected to host the olympiad according to their indices(in ascending order). And this process continues until there is other city to add to $$$d$$$. Thus, we can answer queries $$$q_i\in[timer, timer + (cur - prev) * d.size())$$$, where $$$prev$$$ is number of hosting years of all cities in $$$d$$$ and $$$cur$$$ is first city with number of hosting years larger than $$$prev$$$. For query $$$q_i$$$ the answer is simply a city with order of $$$((q_i - timer)\mod{}d.size())$$$ in ordered set $$$d$$$. Then we can add new cities(cities that hosted $$$cur$$$ times) and continue this operation.

              Hope this was helpful, I struggled with English and LaTeX very much :)

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

    I solved it in $$$O(q log(q) + m log(m) + q log(m))$$$ using Treap but finished the implementation when the contest was already finished :( 55644594

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

How to solve E?

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

    Let's solve the problem recursively. If $$$n=1$$$, the answer is "YES". Otherwise, we have to find a horizontal or vertical line which separates rectangles into smaller ones without intersecting any of them. If no such line exists, the answer is "NO". If it exists, we can greedily assume that it was the line of the last merge and solve problems recursively.

    So, $$$O(n^2)$$$ (maybe $$$O(n^2 \cdot \log(n))$$$) is easy. How to speed it up? We'll try something like "smaller to greater", but in reverse. As we'll split the problem into two smaller ones, we can do it in complexity $$$O(size\_of\_the\_smaller\_part\_after\_the\_split)$$$ (possibly multiplied by $$$O(\log(n))$$$) and the overall complexity will be good. The problem is that we don't know if the line that we are looking for will be horizontal or vertical and we don't know if it'd be closer to the beginning or to the end of the list of sorted rectangles.

    The solution is to try every option at the same time. Maintain $$$4$$$ sets, one for each possibility, go through each of them and if you'd find a good line, stop here, split each set into two smaller ones and the complexity will amortize.

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

      You can change set into list or 2 stacks and this solution will work in O(n log n).

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

How to solve D? can you help me.

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

    I pre solved it in an offline manner.

    1. Sort all the queries in terms of time stamp.
    2. Interate through all the queries and merge the candidate cities in the process. I used two pointer like approach and fenwick tree to maintain this.

    You could read my submission first if it passes. I am currently away from my laptop.

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

So I will wait for Div.3 to raise my rating xD

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

B was incredibly time-consuming in my opinion. I hate strings, it took me 150 lines of code to solve B and I couldn't even submit it in time. After half an hour of coding B I realized that there's like a 100k digits and I can't sum the string as numbers but as strings, so this was my first time ever doing this and i hate it, I hate strings, they're just tedious things that are very easy to mess up because there's so many things that you need to do with strings to manipulate them that its very easy to mess up the code and then debugging takes a lot of time. And I unknowingly solved A within 10 minutes but because I forgot about long long, I thought that there was a math error in my code, so I just skipped A.

At least I learned something..

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

    You should study some accepted submissions and learn simpler ways to approach the implementation. Then you can stop hating strings!

    Here is my B. ~40 lines, 15 min.

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

    String manipulation is much less annoying in python (in my opinion). My solution was less than 30 lines (and wasn't really optimized), so you might consider using a higher level language. Edit: 13 lines after cleaning up my code a little.

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

    Such problems are easier to implement using languages which already have built-in support for large integers, like Python and Java.
    It is always handy to learn the basics of such language (assuming you use C++).
    55623625 Python solution in 8 lines.

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

About problem B. The complexity of adding 2 strings is O(max length of 2 strings). I added 2 trings with max length <1e5 three times but I got TLE. I couldn't solve B. Can anyone explain? Thank you very much.

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

Am I the only person who felt this contest was boring, with lengthy statements and implementations?

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

    I'm not rated high enough to give an expert opinion about this contest, but from my perspective, this was a pretty lame contest. One or two more sentences in each problem to clear some stuff up would go a long way to helping us solve these problems, I feel like some of the information in the tasks were withhold from us just so the tasks would be harder to solve.

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

Do B have weak test cases

I found many codes which fail on

5 10100

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

Fast Testing...Btw i did not like B at all

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

power of system test -> 1200 — 3086

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

0 doesn't have leading 0. but in problem B it have !!!!

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

    From the problem statement: "To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a POSITIVE integer without leading zeros." 0 isn't a positive number.

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

very hard and boring and just implementation

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

B is not fair for C++ ( and other programming languages which do not have bigint library ) programmers.

I solved B using python in 40 lines while C++ needs 100+. ps. sorry for my poor English...

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

    Also, end cases were not covered in the pretests.

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

    55636748

    This doesn't look like a 100 lines.

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

    Honestly, it wouldn't take more than 3 one liner functions to get the same features.
    But I agree, it is unfair to C++ users.
    they'd have to spend precious minutes writing those functions and it could make the difference between rank 400 and rank 14.

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

What is C test case 20? Anybody else fail on that case?

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

E1 can be solved by simply dividing, now the problem is how to get an $$$O(n \log n)$$$(maybe) algorithm to solve E2.

Pls help me.

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

    Let’s optimize dividing. When we are finding cut, we do it in O(number rectangles in one part). Let’s go in 4 directions in one time and cut min part.

    Also, when we found cut, we should erase one part and keep correct orders in 4 directions. We can do it using stack or list.

    This solution works in O(n log n). (We gave here TL from the original contest, where you can solve this problem with python.)

    (Sorry, more details will be in editorial)

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

      I coded it and got ACCEPT just now. Without doubt this is a really cool problem, thank you!

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

    hint: for a subset of rectangles $$$A$$$, you probably have some function $$$solve(A)$$$ which splits $$$A$$$ into $$$B_1, B_2$$$ and returns $$$ solve(B_1) \text{ } AND \text{ } solve(B_2) $$$. The problem is that this splitting takes $$$O(|A|)$$$. Can you make it take $$$O(min(|B_1|, |B_2|))$$$ instead (with some log-factor)?

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

Щас бы давать длинку на контест.

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

I had a mistake in adding long numbers. Very irritated now.

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

А онсайт результаты можно где-нибудь увидеть?

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

Could anybody please tell why this submission doesn't work for problem C? https://codeforces.com/contest/1181/submission/55645536

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

Too bad. I can't solve more than 2 problems in a contest that's meant for school students.

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

Когда В на длинку:

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

Time to become Expert!

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

Мы немного задерживаемся с публикацией разбора, в связи с проведением онсайт соревнования.

Но вы можете пока посмотреть презентацию.

upd а вот теперь есть разбор

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

Problem A has 16 tags now. :O

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

Next Div-3 contest is converted to the div-2 contest. lol...

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

There is change in figure of problem C,but no announcement of it -_-

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

Got tle on D, put #pragma GCC optimize("O3") and ios_base::sync_with_stdio bla bla bla and got AC with 889 ms.... damn it hurts...

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

Any hints for problem C? (not in a complexity of 1e9)

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

    n²log(n)= 660000 if you use segment tree to get how much you can extend the flag

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

    Build 2d-prefix array for each character, then consider each $$$(i,j)$$$ as the bottom left corner of the flag. Binary search the heigh of one stripe — the maximum value of $$$h$$$ such that all characters from coloumn $$$j$$$ in range $$$[i, i + h)$$$ are equal. Then check wherher all characters from $$$j$$$-th coloumn in ranges $$$[i+h, i+2h)$$$ and $$$[i + 2h, i + 3h)$$$ are equal. If not — $$$(i,j)$$$ can't be the bottom left corner of the flag. Otherwise use binary search again to find the maximum value value of $$$w$$$ such that all characters in rectangles $$$[(i,j), (i+h-1, j+w-1)]$$$, $$$[(i+h,j), (i+2h-1, j+w-1)]$$$ and $$$[(i+2h,j), (i+3h-1, j+w-1)]$$$ are equal. (Here $$$[a,b]$$$ means the bottom left and top right corners of the rectangle). There is exactly $$$w$$$ possible flags having cell $$$(i,j)$$$ as their left bottom corner, add this value to the answer and procced to the next cell.
    Here is a bit prettified version of my solution: https://ideone.com/dKdcpu

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

    For each j from 1 to m, we count number of submatrices which left most vertices are in column j. To do so, we divide column j into a list of segments of consecutive characters, for example: 'aabbbcd' -> (1,2) (3,5) (6,6) ('aabbbcd' is characters of column j)

    For each 3 consecutive segments, let x, y, z be lengths and c1, c2, c3 be single characters of 1st, 2nd and 3rd segment. For above example, with segments 2, 3, 4, we have: x=3, y=1, z=1, c1='b', c2='c', c3='d'.

    Now we can get the start of correct flags here if c1 != c2, c2 != c3, x >= y, y <= z. Then we can do binary searching to find maximum length which we can append from the start to get a correct flag. Assume it's d, if d = 0 then it means we can't append anymore from the start, and result += 1 (the start). So result += d + 1.

    When do binary searching, we have to check whether all three strips have only one character. To do so, we can precalculate 2d prefix sum of 26 characters.

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

    We can do it in O(n*m)

    Hint : Consider only flags of width one.

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

Could someone please help me figure out what is wrong in the 9th test case in problem B. Here is my submission 55649908. Thanks in advance.

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

    Try for this test case

    3
    110
    

    Your program gives the output 11 which is wrong because splitting 110 into 11 and 0 is not valid. Both numbers should be positive without leading zeroes.

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

    My logic was to look at the correct split point as close to mid point. Is this logic correct Also im not understanding the comment on my answer Could someone please help

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

      Your logic is correct. I think the problem is with your add function. Just try this case

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

      I didn't check your code, but maybe it is wrong because you need to check splitting not only in mid index (if possible), but in mid + 1 and in mid — 1 too (again, if possible).

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

Weak test cases for problem B

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

Had a screwed up contest, when will the editorials be out?

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

Editorials?

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

Why did this 55636748 get accepted when it is failing for test cases like

2
55

and

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

Can anyone help me with a test for problem B? This is my solution and i can't find where the bug is https://codeforces.com/contest/1181/submission/55659680

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

How could one prove the corretness of greedy splitting in E?

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

    Let’s look on some correct splitting. What changes then we cut some line? Some next cuts will split set of rectangles in two parts with empty one. All those cuts should be deleted. After deleting correctness doesn’t change.

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

      Please, tell me if i understand well.

      If we look at some correct splitting, we can add this extra horizontal or vertical line, and then some regions may be empty ( without castle ). We can always merge this regions with their neighbours by deleting some parts of existing lines in order to achieve one castle in one region. Is this correct, or am I missing something?

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

        You are absolutely right!)

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

          Ok, thank you for your reply.

          There is actually one more thing im not sure about. After doing this operations shape of some regions may change. How do we ensure that it is always possible to merge them one by one ( finally achieving the whole rectangle ). Some of them will change they size so why is it always possible to obtain correct soltuion? Some of the initial mergings may be not available now.

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

Can you guys help me to debug my solution to problem D? I used a treap to update and find the kth smallest. Code : https://codeforces.com/contest/1181/submission/55663264

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

Nice contest, but way too heavy on data structures. My beginner students were struggle a lot.

Even B uses big integers.

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

Could someone explain why is it that in Problem C 10^9 operations also get accepted. Shouldn't that give TLE. Thanks in advance.

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

getting runtime error on test case 10 in problem D. https://codeforces.com/contest/1181/submission/55675351

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

Thank you for opening the contest.

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

When a new girl enters the class. Boys be like: