Автор MikeMirzayanov, 9 лет назад, По-русски

Добрый день, Codeforces!

Совсем скоро, в четверг 11 мая в 18:35 (московское время) начнется Playrix Codescapes Cup. Вас ждем рейтинговый комбинированный раунд, который открыт для всех и каждого!

Задачи для вас предложили и подготовили KAN, Al.Cash, MikeMirzayanov и fcspartakm. В раунде будут задачи как для участников из Div.2, так и для Div.1. Надеемся, вам будет интересно.

Мне всегда приятен интерес со стороны компаний к нашему сообществу. Вдвойне приятно, когда узнаешь, что российская компания находится в самом топе своей нише в мире. Вот только недавно я читал статью о Playrix, а сейчас они проводят соревнование на платформе Codeforces и ищут талантливых разработчиков на C++. В программе призы топ-5 и футболки топ-50 участникам раунда!

Слово руководителю московского офиса Playrix Алексею Трушкову.

Всем привет!

Компания Playrix и Codeforces объявляют о запуске первого Playrix Codescapes! На кону ценные призы, а лучшие 50 участников получат памятные футболки.

Призы:
- Топ 1: iPadPro 9,7 + PowerBank + футболка с логотипом
- Топ 2-5: PowerBank + футболка с логотипом
- Топ 6-50: футболка с логотипом
- (Новое!) Случайные 5 участников (не топ-50, сделали хотя бы одну попытку): футболка с логотипом

Playrix – это команда из более 500 профессионалов, которая занимает первое место среди разработчиков мобильных игр СНГ. Вы можете подумать: «Мобильные игры? Зачем им сложные алгоритмы?». Нашел, что три фишки одного цвета собрались в линию – вот и все. А вот и нет! Сделать игру, которая была бы одновременно красивой, быстрой, и укладывалась в жесткие ограничения объема памяти и быстродействия мобильных устройств – та еще задачка. Чтобы с этим справиться, нам часто приходится применять весьма сложные и нетривиальные алгоритмические решения. Мы публикуем о них статьи habrahabr: о тонкостях FSE кодирования и оптимизации игры с помощью полигональных атласов, например. А бывает, что конвертеры графических форматов, созданные именитыми фирмами, не устраивают нас ни по качеству, ни по быстродействию. И тогда нам приходится создавать свой. Это далеко не полный список сложных задач, возникающих при разработке наших игр.

Мы делаем все, чтобы наши программисты могли сосредоточиться на интересных задачах, и ничто не отвлекало их. Компания предлагает как удаленную работу, так и место в одном из 10 офисов. Вам предоставят всю необходимую технику и доступ к программам и сервисам. Также дважды в год проходит внутренняя конференция PlayrixCON, в рамках которой проходят встречи и круглые столы для программистов. Словом, в Playrix вы найдете интересные задачи, возможности для развития и комфортные условия работы.


Заинтересовались работой в Playrix?

Узнайте об актуальных вакансиях Playrix на job.playrix.ru

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

  1. tourist
  2. LHiC
  3. subscriber
  4. W4yneb0t
  5. enot110

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

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

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

ого я взволнован
p.s. вот этими вот призами вы только народ дразните типа вот гроссы их возьмут а не вы азаз
p.p.s. вот этими рандомными призами вы ещё больше народ дразните, типа рандомные ноунеймы их возьмут а не вы азаз

upd. я вот не получил футболку сейчас и мне неприятно

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

    Мне кажется давать совсем случайным участникам странно. Я бы понял, если

    Случайные 5 участников (не топ-50, сделали хотя бы одну успешную попытку): футболка с логотипом

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

why all of the jobs in codeforces are for Russian-speaking contestants?

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

Register again. Previous registration has been cancelled.

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

How many problems?

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

Tourist winning another round ? Hope he participates.

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

Мне одному кажется, что у девушки на фото очень длинные руки?

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

tourist will complete his set of apple products.

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

Posted time: 15:35 UTC

Actual time: probably 15:45 UTC

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

Hi, everybody.

The offer to organizers from the company Playrix

Considering that the Playrix is engaged in development of games, I would advise to bring some spirit of surprise in a contest :) For example, to add 3-5 small prizes (or T-shirts) which by a randomly method will get to participants outside the first hundred, and maybe the first thousand. It would stimulate attraction to a contest of players.

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

It would be great if you will announce such events more than a day before. Thanks.

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

Problem prepared by MikeMirzayanov! I'm not gonna miss it.

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

I predict there will be an obscure Geometry problem.

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

T-shirt on girl is really great :D

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

I hope there won't be delay before the contest.

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

Dafuq happened to the right hand of the t-shirt girl?..look at those veins :O

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

Hope it's easy to understand all the problems, And all participants will enjoy the contest. :)

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

Is her (t-shirt on girls) right hand > left hand :D ?

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

The T-Shirt Looks Nice

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

How does back of white T-shirt look?

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

а когда обьявят тех кто получил футболки рандомна ? после раунда или как ?

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

Заметил ошибку во времени начала контеста. На странице соревнований начало контеста в 19:35 (по Москве), в анонсе начало в 18:35 и отсчет времени идет до 18:35.

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

Rating prediction,

Extensions:

Have fun & high rating:)

PS One guy wrote to me that he couldn't install extension. Does anybody else has the same problem?

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

how many problems???

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

Футболки очень красивые!)))

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

T-shirts very well

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

Is my luck so poor?

I never get a random prize.

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

i think that it will be a little bit tricky one and challenging too.....

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

What about scoring distribution?

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

The '#' took the perfect place in the picture.

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

Expecting a 10 minute delay. xD

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

How many problems? What's the scoring distribution?

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

Look at girl's right hand. What is that monster dude...?

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

wow.. no delays .. so unusual ..

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

hope to be in random 5 !!!

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

MikeMirzayanov please give tourist a new color :O

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

is that "t-shrirt" is just layer? there also this picture with another t-shirt

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

Трудные однако задачи

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

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

how to solve D?

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

Congrats tourist , i was spectating whole round lol

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

How to solve C?

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

I think it's awesome how computational geometry problems can be so conceptually simple and yet so hard to solve in contest time (ok probably because it was the last question too).

What's the solution for E? (I get the strange feeling that some sort of clever gradual refinement might somehow pass, since it is almost a linear programming question.)

Edit: seems like modified mincost maxflow might work...

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

Great contest I liked the problems very much...C was a little bit tedious tho.

How to solve D ?

:)

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

There are random t-shirts again, so we will use a similar algorithm to the one used several months ago. We have a pseudo-random generator based on testlib.h. The seed will be the winner score in the Tinkoff Cnallenge Final Round on Saturday. The printed integers are the winning places, the ties are broken by the time of last AC.

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

I need help in Problem D.

I need to solve this Subproblem.

Given an array A = [a1, a2, a3, ..., an] and an Integer X.

Get a Sub Sequence B = [b1, b2, b3, ..., bm] from array A such that b1 * b2 * b3 * ... * bm is >= X and as minimum as possible.

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

Submitting problem A and passed pretest: YES! I did it! I'm the f**king genius! Let's check the dashboard. WTF?! tourist solved problem E already?

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

Due to technical reasons the system testing and the rating update will probably be delayed a bit.

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

Hi:

I understand that the contest is finished, but is there a way to still submit my code, just to test for myself..?

Cheers

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

"В" было реально проще, чем "А".

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

The contest is over but I am not able to see the submissions of other users. Why is it so?

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

For C, I separated coins and diamonds. Applied knapsack on both of them individually. Then I just checked the maximum 2 values that can be generated taking care of if 2 fountains cannot be generated. Is this method wrong?

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

In some last minutes, I used brute force way with O(n^2) for problem C and passed the pretest. So the pretest is weak and it is the chance for some cheater who passing it by this way, then open other solution in the same room to find the "real" solution.

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

Why was the memory limit so tight in C? I got memory limit exceeded with only 2 segment trees and total memory of around 12 * 105. My contest got ruined because of this :(

By the way, how much memory can I declare when 256 MB is the limit?

Edit: Nevermind, memory limit wasn't tight. I'm just stupid.

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

Hats off for strong pretests. Update: I meant in D mainly, and I didn't see many hacks in general.

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

Someone know why MLE here http://mirror.codeforces.com/contest/799/submission/27036789 I only use 10^6 integers or where am I wrong?

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

    You can't see others' submissions before systest. Can you pastebin it?

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

      Sure, it's a little ugly

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

Were there pretest on D that needed rotation before answering? Its sad that after trying optimization to fit into tle , i forgot this part and now i will get WA...

»
9 лет назад, скрыть # |
Rev. 4  
Проголосовать: нравится 0 Проголосовать: не нравится
Why my solution Memory limit #4

I don't undertstand
About my memory MX=1e5; two (int,int)[4 * MX] = 2*4*4*4*MX = 128*MX two int MX = 2*MX all 128 * MX + 2 * MX = 130 * MX I think int array[1e6] = 4 Megabyte I tnink **** **** **** ******My memory about 50 Megabyte + (void with other) <= 256 Megabyte**

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

How to solve A? xd

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

    We can iterate through time and compute the number of cakes that we can do in that time.

    for (int time = 1; true; time++)
    {
      int cnt_cakes1 = ...; // Number of cakes WITHOUT second oven.
      if (cnt_cakes1 >= needed_cakes)
      {
        cout << "NO";
        return 0;
      }
       
      int cnt_cakes2 = cnt_cakes1 + ...; // Number of cakes WITH second oven.
      if (cnt_cakes2 >= needed_cakes)
      {
        cout << "YES";
        return 0;
      }
    }
    
  • »
    »
    9 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    I solved it like this: First, I calculated time needed for oven 1 to bake all the cakes. t1 = ceil(n/k)*t

    Then I do t1 — t which is the time the last batch of cakes were put in the oven. If it is less than equal to d, there is no need to build another oven.

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

    if (d // t) * k + k >= n then answer is NO, else answer is YES

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

Can someone tell me why my approach for C is wrong?

First, I try to match 1 fountain of C with 1 fountain of D. In that case it will be the most beautiful of each one that I can afford. The other case is to get 2 fountains of C or 2 fountains of D.

So I sort them by cost, and build a segment tree of maximum beauty within range. Then, for each fountain, I take its cost and binary search the most expensive fountain that I can afford (which will give me an index j in the array the segment tree was based on). Then I just query the segment tree for the range (i+1, j). Then take the maximum of every iteration on both types.

Code: https://ghostbin.com/paste/ogevq

Wrong Answer on pretest 4.

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

Why aren't others solutions visible?

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

Just wish I am lucky enough to get a T-shirt, please :)

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

Any help in B please?

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

I solved B using set in O(mlogn) but my solution didn't care about number of colours, though it was limited to 3. So now I wonder whether it can be solved in linear time or not?

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

Great contest!

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

Why WA11 on E? Can somebody help me?

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

Why TLE on B 27019672. As far as i know the erase function returns number of elements deleted.

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

My solution to problem C got WA because I was comparing a price with a beauty by mistake, the idea was to compare two beauties. After the contest I fixed that and I got AC. How could the first solution have passed the damn pretests!?

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

WA on 27 in D. ARGHHHHH!

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

The Magic returns again Random_shuffle (: http://mirror.codeforces.com/contest/799/submission/27038984

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

So weak pretest on C. Jesus, there was only 10 tests and all of them were soooo simple. Nice trap)

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

Problem B-: link-: http://mirror.codeforces.com/contest/799/submission/27030194

Can any one please have a look at my code it gives Runtime error on pretest 9 ??. i can't figure it out why..??

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

    You should store (*it) in a variable then delete it from various sets. Consider x=1 and v[1].size()=1. You first delete it then use (*it) for i=2, and i=3 which is invalid and cause run-time error.

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

You know you are legendary when you fail E on system tests but you are still the first

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

Кто-нибудь может объяснить нормальное решение D? У меня такое чувство, что я просто загнал лажу, жадно проверяя ответ от 40 до 0

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

    Наблюдение : достаточно первых 40 элементов в порядке убывания, т.к каждая сторона расширяется не более 17 раз. Более того, так как порядок использования нам не важен, разумно брать максимальные доступные значения.

    Тогда пишем dp[turns][width] -> max height

    Пересчеты примерно такие: можно либо расширить width в a[turns] раз, либо расширить max height в a[turns] раз. Если прямоугольник (width, dp[turns][width] * a[turns]) или прямоугольник (width * a[turns], dp[turns][width]) дает нам ответ, то ответ равен turns + 1.

    В противном случае релаксируем значения в turns + 1 :) Немного сумбурно, надеюсь, кодом будет понятнее. http://mirror.codeforces.com/contest/799/submission/27031985

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

27040141

this submission should get wrong ans

printing -1 for this case

100000 100000 1 1 4

99999 99999 99999 99999

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

В D кроме дп заходил пребор по i (количество использованнных чисел (<= 34), к тому же понятно что надо использоватьтолько максимальные i чисел), если перебирать сколько копий какого-либо из максимальных чисел мы используем для увеличения h, и, соответственно остальное для увеличения w.

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

    Круче! Заходит перебор первых 19 чисел для одного из чисел и заполнение второго жадным образом. В минимальном тесте, который мог бы это сломать будет 19 троек и 2 двойки, а 3^10 * 2 > 10^5, поэтому всего можем поставить 9 троек и двойку так, чтобы взять всё. Что приводит к 18 тройкам и 2 двойкам в тесте и уже перебирается решением.

    Надо только поподставлять первым числом и w, и h. Типа все 4 возможных комбинации инпута чекнуть.

    // К сожалению, на контесте до такой идеи мне чутка не хватило) В дорешку уже закинул. http://mirror.codeforces.com/contest/799/submission/27039226

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

Кто-нибудь не подскажет когда разбор подъедет?

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

c 27040159

what is the problem with this?

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

The results (and rating change) are not final yet, the final results will be within several hours.

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

what is problem of this code

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

Why they made pretest in D so that you don't need to swap(a, b) in no way ant it still passes pretests, when after real tests it fails :/ My solution

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

D was such an amazing problem indeed

I guess my solution is a bit odd but it takes 78ms to finish

My idea was to deal with the easiest two cases separately, that's when the answer is 0 or 1

For the general case:

We are told that the smallest ai value is not less than 2, which means that in worst case we need 17 elements for each side a = b = 100, 000, w = h = 1, n = 100, 000, that's 34 elements at most, cool isn't it

Well that number 34 makes it seems like it's dynamic programming with bitmasking, hmmm maybe but I couldn't utilize this fact much

Anyway let's take a look at the worst case, we have 34 elements and we need to choose a subset of these numbers, multiply them together with one of sides, then multiply the complements of said subset with the other side and check if we can enclose an a * b inside

But 34 is a big number, I would gladly do something like that if it was something like 17, but hey, what if split it into 2 halves, each of which is at most 17 elements, that's 217 subsets -- we can sort the second one in descending order and then loop over each subset in the first half, for each one I want to find the best match in the second sorted half, we may add with each subset the value of its compliment, do something like partial sums over them such that subcomplement[i] = Maxi: subcomplement[0..i]

Now we can do for each subset in first half a binary search over the range of subsets, if we can satisfy:

w * subleft[i] * subright[l...r] >  = a and check if h * subleftcomplement[i] * subrightcomplement[r] >  = b or when w,h are swapped and a,b are swapped i.e. four cases then there is a solution using 34 elements

We can try to reduce the count to the half and repeat the process around log2(34) times

Basically we are doing binary search over answer (count) and using meet in the middle technique to check it quickly

Not so sure about the big-O though, may be O(2m / 2 * log2(2m / 2) * log2(m)) and m <  = 34

Anyway here is the link

27042867(Submission link)

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

    I believe the expected solution was along these lines. I was trying to do something similar during the contest time. However, I am still not sure how many people got a simple bfs like solution to pass this constrains. It seems like they are actually exploring a tree with a branching factor of 2 (either multiply the current number to w o h) and the shallowest solution can be upto depth 34. Obviously many branches can be easily pruned but why was this optimization so significant?

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

      For a fixed set of extensions, let the final area of the field after applying all of them be A. Then if A/(a*b) > 100000, there must be a solution (Consider moving field extensions from the width to the height 1 at a time).

      So A < 1e15. Notice that all states we have are divisors of A, and that no number below 1e15 has too many factors (cannot remember how many, but it's way way less than 2^30). Thus pruning is very effective.

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

        Wont there be multiple states corresponding to one divisor of A.Could ou please elaborate on the proof.

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

          This is similar to the knapsack problem https://en.wikipedia.org/wiki/Knapsack_problem. Here the value and weights are the same. Consider the following solution:

          Number the items 1 to n. Consider the set S={0}. For 1 to n, do:

          Update S' to be S union {S*w_i}. That is, we add to the set S the new possible values that we could form with items up to n. To do this, we just need to add at most |S| values, i.e. the size of the already existing set. The pruning of repeated values keep the size of |S| small.

          If |S| is bounded by 100000, then we require at most 100000 operations per iteration of the for loop, which is still a lot less than 2^30, and hence runs in time.

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

    I have done the same. Forgot to swap h, w and perform it again. I used set for those 34 elements. When for a particular mask, I select some of those 34 elements, I remove them from mask and give it to h, then to make w >= b, I greedily reverse iterate on the set till I make w>=b. code

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

    I also thought subsets are 2 power 34 . So dynamic programming might time out. But if u observe states are not distinct unless all a[i] are distinct . The states will keep repeating(and 17 is possible only if all a[i] are two). So as 10! is less than 10^5 . Total states will be around 2^20 or so (this is just intuitive). So this is the reason why dp works

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

The contest dissapeared!

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

Problem C, any case just as test 4 but simpler ?

UPD: AC .. sorry for inconvenience.

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

How to solve problem E? Thanks.

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

    Denote set of decorations liked by both to be A, set liked by Arkady only to be B, set liked by Masha only to be C, and set liked by neither to be D. Sort these sets in ascending order by cost and keep their prefix sums.

    We fix the number of decorations we pick from set A to be x. Then we need at least (k-x) items from set B and set C, and (m-x-2*(k-x)) (call this number KK) remaining items from any set. The (k-x) items from set B and C we can just optimally pick the cheapest items. For the rest, we need to pick the cheapest KK items from any of the sets B,C,and D. Call this final optimal set of KK items to be S. We can binary search for the maximum value M in S (look for the minimum M such that the number of items <= to M in sets B,C,D sum up to more than KK). To do this for each set B,C,D we binary search again for number of items less than M and sum them up. If the minimum such M gives us L items that are <= M, then we subtract (L-K)*M from the prefix sum since all the over-counted items will have cost M.

    Loop through all possible values of x (0 to |A|) and get optimum answer.

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

      I had a similar idea.But I saw many people solve it with segment tree. Can someone elaborate on that?

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

        After fixing x, we are trying to solve the following problem:

        Find sum of z cheapest items in the union of the following arrays:

        • Some suffix of B
        • Some suffix of C
        • All of D

        We can keep a segment tree to tell us this quantity. Note that as x increases, we keep looking at larger suffixes of B and C, so we can keep two pointers for B and C and maintain all the candidate values in a segment tree, and report the optimal sum in .

        Ugly Code

        By the way, did anyone else think that problems A-E were sort of standard logically, and focused more toward implementation? I think there is a huge jump in difficulty from E to F. E isn't really difficult to solve on paper but tricky to code quickly..

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

      Thanks a lot for the help!

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

    I think this problem can be done greedily by using 2 min heaps and 1 max heap. In one heap we will keep all the decorations with weight(cost) for common to both and 2*weight for dec that is liked by exactly one.Second heap for minimum common decoration not yet picked(after all buckets are filled).Third for costliest decoration(belonging to exactly one) which has been picked.If we've not filled all the m decorations we remove from third heap and insert from second one.

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

B.Submitted

Can anyone say why my source code takes 280ms (in n=1.0*10^5) and takes over 3000ms in n=2.0*10^5)? I think it's time complexity is O((m+n)logn)... I guess why the program works slowly is that I used std::deque...?

cf) I used struct to save p,a,b and saved that structs(t-shirts) at the deque(one,two,three) and sorted and when the buyer want to buy t-shirts, I used "pop_front" and "erase" to erase one t-shirts.. I think "erase" is cause of TLE...

please help me

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

    I guess that your idea may be right.

    Complexity Linear on the number of elements erased (destructions). Plus, depending on the particular library implemention, up to an additional linear time on the number of elements between position and one of the ends of the deque.

    quote from:deque::erase

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

I think the final tests for C are too weak. I got AC in the contest 27031840 , but now I realize that I made some mistakes when I decided to reduce the execution time. ex.it will WA on the data below

2 10 0
5 3 C
6 3 C

Now I have fixed the mistakes.27044385 [If you guys can find other mistakes, please tell me. thx!]

Sorry for my poor English.XD

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

Problem D is also solvable with Meet-In-The-Middle.
Here is my code 27046475

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

When will the editorial be available?

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

when will the random 5 participant who get tshirt be posted .

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

When will be the editorial uploaded?

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

for problem C

is it ok to sort by bi/qi and then use binary search?

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

What is the intended solution in F? I've accepted solution with no more than 24n queries to the segment tree in upsolving but had some troubles fitting it in time limit. I've seen some solutions without this data structure, maybe someone can share his approach?

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

MikeMirzayanov KAN, When will you announce the five random T-shirt winners ?

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

Why so serious?  My corrently account is sina-ss you send me whats your problem

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

I have seen solutions of C using fenwick tree( also called Binary Indexed Tree or BIT) such as this one : (http://mirror.codeforces.com/contest/799/submission/27019364) Can somebody explain this ?