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

Автор jzzhu, 12 лет назад, перевод, По-русски

Всем привет! Совсем скоро начнется Codeforces Round #257.

Главный герой задач раунда Jzzhu. Несмотря на то, что мой никнейм jzzhu, Jzzhu — это не я. Сегодня Jzzhu столкнется с самыми разными задачами. Сможете ли вы ему помочь?

Задачи раунда готовили gagaga5-gagaga и я. Мы благодарим ydc, jzc, fanhqme за тестирование задач раунда. Большое спасибо Gerald за помощь в подготовке раунда, а также MikeMirzayanov за создание платформы для проведения соревнований.

Недеюсь, что вам понравится проводить время с Jzzhu!

UPD

Разбалловка для первого дивизиона: 500-1000-1500-2000-2500.

Разбалловка для второго дивизиона: 500-1000-1500-2000-2500.

UPD

Соревнование завершено, всем спасибо заучастие!

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

Победители Div. 1:

1.semiexp

2.kutengine

3.rowdark

4.YuukaKazami

5.mruxim

Победители Div. 2:

1.swenyoo

2.chm517

3.Shinka

4.TBH

5.silly_girl

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

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

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

Wow! Another Chinese round!

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

chinese round month..

and maybe MinakoKojima's round will be come out this month

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

jzzhu != jzzhu ("the real Jzzhu isn't me")

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

I like Chinese rounds because it starts early, but Div1 E is always too hard :v

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

Chinese round, Interesting.

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

It is the third contest which I can not participate because of IOI's schedule. When this contest started, we was on the bus.

I can't participate last 2 contests too, because I must sleep enough to participate IOI contests.

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

Another chinese round. I like chinese rounds because it can involve math and sometimes good problems.

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

Похоже в Китае мейнстрим пошел давать раунды КФ.

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

A Fermat prime number round!

For more info about Fermat theory, click here. It's a theory about prime numbers that are a power of 2 added by one.

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

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

    hard contest or easy!!!

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

      Yes. Or medium.

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

        256؟؟

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

          ส็็็็็็็็็็็็็็็็็็็ส็็็็็็็็็็็็็็็็็็็ส็็็็็็็็็็็็็็็็็็็ส็็็็็็็็็็็็็็็็็็็ส็็็็็็็็็็็็็็็็็็็ส็็็็็็็็็็็็็็็็็็็ส็็็็็็็็็็็็็็็็็็็ส็็็็็็็็็็็็็็็็็็็ส็็็็็็็็็็็็็็็็็็็ส็็็็็็็็็็็็็็็็็็็ส็็็็็็็็็็็็็็็็็็็ส็็็็็็็็็็็็็็็็็็็ส็็็็็็็็็็็็็็็็็็็ส็็็็็็็็็็็็็็็็็็็ส็็็็็็็็็็็็็็็็็็็ส็็็็็็็็็็็็็็็็็็็ส็็็็็็็็็็็็็็็็็็็ส็็็็็็็็็็็็็็็็็็็ส็็็็็็็็็็็็็็็็็็็ส็็็็็็็็็็็็็็็็็็็ส็็็็็็็็็็็็็็็็็็็ส็็็็็็็็็็็็็็็็็็็ส็็็็็็็็็็็็็็็็็็็ส็็็็็็็็็็็็็็็็็็็

          What, are we having a contest in posting random stuff?

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

Chinese here, Chinese there, Chinese everywhere :P after these 3 contests my mom will see me just like JACKIE JOHN

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

Язык сломал пока прочитал никнеймы авторов задач и тех, кто их тестировал =D.

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

hope an easy contest! :)

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

Chinese round again.I'm glad to see it.RP++

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

just Ten minutes remain but a problem rush in my mind: But i will be glad if any of you answer my question : http://codeforces.me/blog/entry/13102

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

I like Chinese round! Good luck and have fun for everyone!

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

what's the problem with hack???

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

провал года:(

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

Как решать A? Правда ли, что нужно сделать как можно больше разрезов по горизонтали или вертикали, и если да, то почему?

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

Первый раз (с учётом предыдущих аккаунтов) у меня задача C (div 2) прошла претесты. Надеюсь, на полном наборе тестов не упадёт.

UPD1. A упала на тестах, глупую ошибку допустил... B и C зашли. Отлично.

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

Great round! I submitted three. Hope they pass systests!

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

Any hint on C except for Blossom Algorithm? Nice round anyway.

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

very WEAK pretests....I'm really afraid of systests...

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

all problems was tricky thanks

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

what was to be done in div-2 C ....

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

    The solution doesn't exist if k > n + m - 2. In the ideal case, after making k cuts, the remaining pieces have equal area. Sometimes, this is not possible.

    First, try to make only vertical cuts in the best way (i.e the minimum area is largest). If k < n - 1, we will have ⌊ m / p⌋ columns in the minimum area. So area is that number multiplied by n. Same way try to make only horizontal cuts.

    In some cases we cannot make only horizontal or only vertical cuts, so we have to do both. Which one to do first? Try both possibilities, i.e. first vertical then horizontal and then first horizontal and then vertical, and then print the maximum resulting area (of the smallest piece) as answer.

    My solution: 7171855

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

D сводится к "для каждого 0 < mask < 2^20 посчитать количество чисел из массива, которые являются подмасками mask". Как это быстро посчитать?

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

    Мб 3*10^9 (если просто перебирать подмаски) зайдет в 2 секунды?

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

      Работало 2.8 сек, и я не знаю как больше ускорить.

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

      Не зайдёт, это первое что я попробовал, когда увидел, что её всё сдают. У меня работало 8 секунд, на codeforces может быстрее, но до 2х секунд всё равно далеко.

      Я запихал следующим образом. Разобьём числа на 4 группы по последним 2м битам, получим множества A00, A01, A10, A11. Сделаем включение-исключение на этих 2х битах, получим ответ: f(A00 + A01 + A10 + A11) - f(A10 + A11) - f(A01 + A11) + f(A11), где f(A) — ответ для множества A, если ограничиться 18 битами (его считаем втупую). Итоговая сложность — 4 * 318, может, чуть быстрее, засчёт того что чисел только миллион.

      Интересно, какое нормальное решение? Upd. Внизу пишут, что есть, и идея баянистая. Хотя надо признать, довольно красивая.

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

    Вот у нас есть граф, в котором мы хотим из некоторых вершин протолкнуть значение во все достижимые вершины. Если проталкивать только в прямых потокмков, а потом проталкивать из них и т.д., то мы посчитаем что-то лишнее, а именно из вершины в потомка на глубине d придет число в (количество_путей_между_этими_вершинами_раз) больше, чем нужно. В таком графе количество путей будет как раз d!

    Дальше делаем maxVALUE * log(maxVALUE) состояний, и считаем все. Память нужно экономить.

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

    Будем перебирать биты от старших к младшим и пересчитывать ответ:

    for (int bit=20;bit>=0;bit--)
    {
     for (int j=(1<<bit);j<=(1<<20);j++)
     if (j&(1<<bit))
      ttl[j-(1<<bit)]+=ttl[j];
    }
    
    • »
      »
      »
      12 лет назад, скрыть # ^ |
       
      Проголосовать: нравится -8 Проголосовать: не нравится

      Похоже можно в любом порядке.

      	for (int bit = 0; bit < 20; bit++)
      		for (int mask = 0; mask < (1 << 20); mask++)
      			if (mask & (1 << bit))
      				ttl[mask ^ (1 << bit)] += ttl[mask];
      

      Но можно пару слов о том как это работает, и почему мы не считаем повторения?

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

What is the approach for DIV2 D ?

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

Problem D is very well known. Have no idea where the tester was looking at. Also naive solution works 3.3 seconds on Java, while TL is 2 seconds. I guess, one may got AC with the same written in C++...

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

Pretest can be weak because I don't trust my code but I accecpted

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

I think there will be a lot of problem C div2 fails.

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

http://codeforces.me/contest/449/submission/7169365 — that code will surely get accepted :DD

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

Is the observation in Div1 D that it is enough to sum the groups of k from 1 to 20 instead of n, correct ? If it is correct how will it help in solving the problem ? I tried to use the dp state (index,k) but I had no idea how to keep track of the mask till this index.

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

The system testing is start

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

это, конечно, смешно, но как нормально решать див.2 В?

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

was there an easier solution for div2 B instead of doing matrix multiplication w/ the linear recurrence? I thought this was a hard topic for a div2 B problem D:

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

problem B has 4 pretests.....WTF!
WHY????????

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

Back to home (div 2) :D

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

How to solve div2-C problem?? please with proof 233333

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

Back to Newbie.

la la la..

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

in Div 2 what is the solution for problem C i got WA what i thought of is there is a 3 cases

1) not applicable if k > m+n -2 2) 1 if k > max(m,n) -1 3) n*m/(k+1) else

?!!

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

problem C in Div 2 was crazy ;(

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

Why is the system testing so slow..?

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

Congratulations semiexp !

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

In my opinion this round should be unrated because it wasn't an unusual round...there were very few pretest. What do you say?

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

BUTTHURT

Серьёзно, поищите различия и ощутите температуру сзади меня

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

Can someone help me find a flaw in my solution to Div.2 D / Div. 1 B? Link to code: http://ideone.com/opD81j

My approach was to calculate the shortest paths to every node from the capital with and without train tracks. Then I delete off as many tracks as possible.

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

Please, help me the problem C div 2? :( I'm try it in 1h30 but it was wrong :(

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

EDIT: Resolved now.

I got WA in http://codeforces.me/contest/450/submission/7160858, but seems other solutions are accepted with same answer ?! What am I missing ?!!

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

Will there be any editorial for these contests?

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

Nearly back to grey...... Anyway just keep on fighting!

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

I was a green coder before this contest,but now I'm purple!

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

Can anyone explain div2D/div1B?

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

Although problem C div2 was hard, but I enjoyed the problems. Especially problem B div2. Thanks for your nice problems.

Won't there be any editorial?

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

Hard round i ever seen... very tricky ..but interesting problems..thanks for setting this contest...

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

I wish the pretests for B and D weren't pointless... I got first submit AC on all pretests, and systest fail on the first non-pretest. THE VERY FIRST ONE. TWICE.

And it's not like there were too many pretests, D had 7 and B just 4. Would it have hurt too much to add several more? Not to mention, there was no real maxtest (just one with unit lengths) included in the pretests of B, which is IMO not a good idea regardless of the problem.

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

    BTW, many wrong solutions failed pretests on B)

    I think it was made this way to increase number of challenges. But most of us just did not found out during the round that pretests are so weak.

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

      Yes, it's a given that many solutions would fail if there are just 4 pretests, out of which 2 are samples. Which is why I'm complaining that the pretests were few and bad. Usually though, it should be "it seems this problem has many tricky situations -> let's try hacking", which doesn't seem like the case with B.

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

For those who got why Div1 A failed so many times: why did Div1 A fail so many times? What's the general flaw pattern?

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

Nice round, but how about editorial?)

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

please any one explain me how to solve div2 C briefly . waiting for editorial but of no use.

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

    I just a few words, you simply have to observe that you divide up one side of the chocolate as much as you can and use the remaining cuts on the other side of the chocolate. You do this for both sides.

    The intuition behind this is quite simple. I think someone above this has already explained but I will explain it here as well. The number of pieces after you make a cuts on one side and b cuts on the other side is (a + 1) (b + 1), leaving the min area to be (nm) / ((a + 1) (b + 1)). You want to thus minimize (a + 1) (b + 1) which is equal to ab + a + b + 1. Since a + b = k, you just need to minimize ab.

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

      bboy_drain We need to minimize the value expr=ab i.e expr=a*k-(a*a).How can we say that value of expr is least when you divide up one side of the chocolate as much as you can?( I'm talking about the case when k>m-1.In this case,how can we say that by keeping a=( k-(m-1) ),we get the least expr value? ).

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

        This is through intuitive math thinking. Let's say k = 6. Let's list out the possible values of ab, such that a + b = k.

        a = 1, b = 5, 5 a = 2, b = 4, 8 a = 3, b = 3, 9.

        So as you can see, the smaller a is, the better, thus we maximize the cuts on one side to minimize the cuts on the other side. The proof is basic math, see if you can prove it yourself.

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

gagaga5-gagaga, jzzhu any updates regarding the editorial?

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

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

I think the pretests are becoming too much weak. Sometimes it makes me wonder if they are even necessary at all. I think they should be made a little more stronger. Recently I've seen many codes of strong coders who are way beyond my level to pass on pretests on one shot but fail within a few cases of the main test cases. And after checking them, the cases were actually simple rather than medium or strong corner cases. Sometimes this becomes a little upsetting. I don't know if others feel this way but this is just my opinion.

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

    It depends on what they are trying to achieve. In the competitions I've participated in the past the solutions were only checked on the samples from the problem statement, at best, so you had to be think carefully before submitting. However, you also got partial score if the solution failed some tests, and no penalty for late submissions/resubmissions.

    It certainly makes more sense to have stronger test cases here, since even a small mistake means you get 0 for the problem, and you get penalized for resubmitting the problem anyway. Still, it doesn't mean that they should include all corner cases (which seems to be the Topcoder approach).

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

      In haven't participated in almost any competitions where the solutions would only be tested on samples. IOI, ACM ICPC, CF rules aren't like that, and many competitions use one of them. TC doesn't really count, because they often have many samples, including large tests. Yandex Algorithm, not. GCJ, not. CodeChef: ACM rules. Various ACM trainings: ACM rules. Most secondary school competitions: IOI rules. Uh... Hackerrank: even more detailed than ACM rules. To be honest, I haven't participated in a competition without feedback for months, and I do almost all there is.

      There are just a few secondary school competitions (like COCI or USACO) that have no feedback.

      The reason for it is clear: you don't have to think carefully before submitting, because a small unnoticeable bug can make you fail easily. If you understand the problem incorrectly and it still fits with the samples, nothing can help you. If you have a small bug that only shows with large/specific cases (yes, there are such situations, converting subtrees to intervals by inorder traversal is an excellent example), you don't have to find it even if you generate dozens of tests and check your code against a bruteforce. Your code can fail on large corner cases. Etc. Even if the problem has partial scoring, you can still fail horribly because of missing a special case (I got 0/100 on IOI 2012 Rings, with exactly one WA in each of 5 subtasks, even with full feedback, and you can easily guess why).

      I don't know if TC really includes all corner cases in samples. It's usually "several small samples demonstrating the problem, sometimes some corner cases, 1 or 2 large samples". I've even had solutions that were so horribly wrong I fail to understand how I could ever write such bullshit, and yet passed all the samples. Besides, their samples are supposed to be the same thing as pretests here.

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

How to solve D1-D using inclusion-exclusion? What's the idea?

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

    Let X denote the input set. . allzero(y, S) returns true if and only if the i-th bit of y is 0 for (similar definition for allone). Then the answer would be . requires m = 20, but I will use m = 2 for better illustration. It's trivial to generalise to the case where m = 20.

    By inclusion-exclusion principle, we know:

    .

    . . . .

    If all Tmask are known, we can simply loop over all possible mask values (220) to get the answer.

    Now let's turn to Tmask. Tmask is the number of element x, such that x&Tmask = Tmask. Informally speaking, if some bit of Tmask is 1, the corresponding bit of x must be 1, otherwise there's no constraint on x.

        for (int i = 0; i < n; ++i) {
            int x;
            scanf("%d", &x);
            cnt[x]++;
        }
        for (int j = 0; j < 20; ++j) for (int i = two(20) - 1; i >= 0; --i) {
            if (getbit(i, j) == 0) cnt[i] += cnt[i | two(j)];
        }
    
    

    Prior to the j-th iteration, cnt[mask] would be the cardinality of the set of x, such that bit 0 to j - 1 meets the condition I mentioned above, bit j to 19 must match precisely between x and mask. Executing the j-th iteration would loosen the constraint in 0 values at the j-th bit of mask.

    The overall time complexity is 20 × 220.

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

My rank changes from 192 to 191 and silly_girl is not from top 5 as writer mentioned is this a cheating case ?