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

Автор cyand1317, история, 9 лет назад, По-английски

Hi!

I’d like to invite you to Codeforces Round #431 which takes place at 16:35 MSK on 1 September. Please note that the timing is again unusual.

One of the problems is created by adedalic and KAN, while the others are authored by me. This is my second round here, and it couldn’t have been realized without efforts of: AlexFetisov, ifsmirnov, Tommyr7, winger and wu_qing who tested the problems; KAN who appears to be a meticulous guide throughout the preparation process; and MikeMirzayanov with the supercalifragilisticexpialidocious Codeforces and Polygon platforms — my deep gratitude to you!

Both divisions are welcomed as rated contestants and will have five problems to solve in two hours. The scoring will be announced later.

Once upon a time, in a virtual galaxy far, far away, there was a lovely young singer by the name of Hatsune Miku. One lovely day, Miku got a job as a vocalist in Vocaloid, and that was very exciting. People said, “Oh, Miku, you sing so accurately! And so emotive, too!” Soon everyone was talking about Miku, and there were songs and paintings and even live concerts for, and with, Miku. Miku liked that.

And you, are to start a journey following the emotions in Miku’s voice. Oh, by the way, a late Happy Birthday to her — August 31 is (was) her tenth anniversary.

For the world you live in, thank you.

See you then, and wish everyone few bugs and fair ratings.

UPD 1 Scoring will be:

  • 500-1000-1500-2000-2500 for Division 2;
  • 500-1000-1750-1750-2500 for Division 1.

UPD 2 System test is done. Congratulations to the winners!

Division 1

  1. dotorya
  2. Reyna
  3. SkyDec
  4. V--o_o--V
  5. ko_osaga

Division 2

  1. lmmortalCO (solved all problems!)
  2. ltg2030
  3. FoolMike
  4. HatsuneMiku
  5. MisakaKuma

Also, thanks to all who participated! Nicely done!

Check out the editorial with hints!

UPD 3 Complete tutorials and behind-the-scene fragments are out. Problem packages may be published soon, stay tuned!

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

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

Miku? I'm in!!

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

want some downvotes, just ask is it rated? Just see my downvotes.

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

"supercalifragilisticexpialidocious" what ? :|

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

Two Faced Lovers <3. Tell your World <3. Miku Hatsune <3. Rated Div 1 contest <3.

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

I am new to codeforces... So can i join the contest? Because its asking for ratings...

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

I just realised Hatsune Miku literally means first sound from the future.

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

I as well would like to know in the fullist if this contest on the code force will count towards my codeforce rating on the codeforces.com webite on the internet on the wires that are inside the tubes that the internet is made of.

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

Happy Eid for you all :D

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

Probably the best english I've read in a long time on CF, hope the problems will be as easy to read as the announcement :D

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

6:35 AM? Seriously? Gonna participate it for Miku Hope this round will not be a typical China round :P

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

bilibili (゜-゜)つロ che.... Oh wait wrong platform.

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

"Soon everyone was talking about Miku, and there were songs and paintings and even lives for Miku.

I'm sorry, what?

Have I missed the weekly sacrifice? I thought it was called off.

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

My birthday.Oh yeah! I'll be glad to with you in codeforces.>w<

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

Hope for good quality problems :)

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

Codeforces with Miku is so good!I will be definitely in!!!(Although I 'm so weak...)

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

Am I the only one who doesn't know about Hastune Miku?

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

Please don't use these hard names in problems please. It makes difficult to understand also is it rated?

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

Eager to participate after a long time -> See Miku in the blog -> Decided to go to sleep instead.

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

Awesome feature of showing rating change in leader-board during the contest.

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

i hope there won't be long stories about Miku in the statements..

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

I know a sentence to get lots of downvotes,but I will not say

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

Happy birthday, Hatsune Miku! Thank you for bringing so many wonderful songs to us!

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

Codeforces means nothing, Miku means everything.

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

bilibili (゜-゜)つロ chess!!!Happy birthday Hatsune Miku!!!

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

Last line of the blog : "wish everyone few bugs and fair ratings." :(

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

I am getting error : 502 bad gateway..

If it is problem of the site please check it so that it wont effect the competition.

Happy Coding!

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

Hope this round be rated!

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

Ох щас бы 502 покидать на каждый второй запрос. Надеюсь, раунд не перенесут, всегда это немного раздражает. Я вот например только что встал именно из-за раунда!

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

Another anime-contest?) This year have many anime-contests)

Maybe next year will have >= contests with anime theme? Does someone else want it? :)

Good luck everyone! 502 will not stop us!

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

Please, don't start the contest till you fix the problem 502 Bad Gateway

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

Eid Mubarak to everyone :-)

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

Hope, 502 Bad Gateway don't appear during contests!

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

Scoring?

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

Miku~

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

And the count down starts...10, 9, 8, 7,...0

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

let it begins

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

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

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

Not able to hack ..... page is stuck at reloading again and again...

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

There are no memes in the comment section?

spits coffee

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

so after forty minutes i didnt solve problem a or problem b

i give up :( i should stop doing cp

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

Moderator I hacked the solution of user — "redcpp". verdict is saying unsuccessful but in his logs its written that his solution is hacked by me. Update marks.

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

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

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

Titles are all Hatsune Miku songs~

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

Currently 22 minutes left until the end of the contest, and I have been trying to hack one of roommate's codes for the last 5 minutes (with this error).

EDIT: I was eventually able to (successfully) hack this code, however I couldn't hack the (incorrect) code of another participant due to this error. And after repeatedly refreshing the page I saw that the participant had resubmitted a correct code (without being hacked by anybody else).

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

Div. 2 + Div. 1 round? More like Div. 1 + Div. 0 round. RIP Rating.

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

How to solve div2 d?

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

    sort

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

    for horizontal , consider the point to be at ( - ti, yi)
    for vertical , consider the point to be at (xi,  - ti)
    Now consider each diagonal (Same x + y) at a time
    Only points among the same diagonal will collide and each point's direction will alternate after each collision.

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

    First notice that instead of looking at time the person starts, you can simply set their x/y coordinate to -t (depending on what way the person is facing). Then notice that instead of imitating a collision, you can just swap the indexes of the people colliding, since they just swap trajectories. Then also notice, that you can place people in buckets based on the sum of their x and y coordinate (people with the same x+y go into the same bucket). In those buckets, every vertical person will collide with every horizontal person, and vice versa. Now, next thing to notice is that every horizontal person will hit vertical people in the order of their x coordinate. Therefore, the last index that carries that trajectory will be the index of the furthest right vertical person. Yes, there's a lot of noticing in this task. At this point you could probably implement it, but there are a few more things to notice if you want to have a nice, clean implementation, but I don't know how to explain what I did, so I'll leave it as practice (if someone really wants to I can try to explain)

    Also, cyand1317, I absolutely loved this task, thanks!

    Edit: while I typed this someone already answered. I hope this will still be helpful to someone!

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

      Thanks for the explanation, for me it's much easier to grasp than official editorial. Only last step (how to properly sort dancers and final points, then match them) is to be applied to your solution to get ACC. It's described in editorial, but if you don't mind I will explain it here to finish your solution.

      If you sort all dancers in one bucket wrt their initial x positions (for horizontal dancers it will be -t_i, and x_i for vertical ones), and sort all final points for this bucket in order (0, h)->(w, h)->(w, 0), you may realize the next thing:

      1. Dancer with leftmost x position will be always horizontal and it will end in the first (at the top of field and leftmost one) final point for this bucket (because when it collides with some dancer it immediately goes up with no collisions)
      2. The second dancer is actually the one who will make this only collision with the first dancer (then the first dancer goes at the top of the field). Then, if there are more final points at the top of the field, then second dancer will collide some vertical dancer and will go to this point. If there no such final points, second dancer will have no mroe collisions and goes to the second final point (with coordinates (w, y_i))

      The same logic could be applied to the next dancers... Just imagine the picture and you will get the idea.

      I hope this would be helpful for someone who doesn't want to spend 5 hours on this problem:)

      My submission.

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

Supercalifragilisticexpialidocious problem C. (E div 2). Thanks >__<

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

The first time getting rank 25 in div.2

:)Happy

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

Did anyone pass problem DIV1 C with Mo algorithm working in O(n^(5/3))?

Btw by n^(5/3) I mean this optimization : http://codeforces.me/blog/entry/44711?#comment-292040

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

How to solve div1B? I feel so stupid

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

    Suppose a dancer travelling vertically having position Xi and wait time Wi, and a dancer travelling horizontally having position Yj and wait time Wj meet at time T. Hence,

    (Wi + T) = Yj and (Wj + T) = Xi

    This will be used to check collision condition and time.

    (Xi - Wi) = (Yj - Wj) and T = (Xi + Wj)

    Now, sort dancers travelling vertically by Xi and dancers travelling horizontally by Wj. Store dancer indices for each distinct difference (Xi - Wi) and (Yj - Wj) for each type of travellers.

    For one particular difference, consider 2 vectors, 1 of horizontal travellers and 1 of vertical travellers, each element of 1st vector will intersect with each element of 2nd vector. Final positions of dancers from these 2 vector will just interchange among themselves independent of other dancers.

    Collision happens in sequential order. That is i from vector 1 will intersect with j1 and j2 from vector 2 in order of j1 and j2, same holds other way.

    This sequential order can be used to decide final position of each traveller of these 2 vectors combined in O(n). You just need to traverse these 2 vectors in particular order. Sorting the travellers takes O(n * log(n)) time.

    Code

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

    Don't, it was pretty hard (IMO).

    You can group the people, so in one group all possible collisions happen, and no collision happens between groups. You have to group by pi - ti. The previous statements can be proved, for same and different pi - tis. After that, you can solve the problem for one person in O(1). I'll leave that thinking to you :)

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

How to solve div1C?

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

I am surprised that I found Div-2 C pretty hard, but still more than 1000 participants solved it. Looking forward to the solution.

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

    a => 0 aa => 1 aaa => 3 aaaa => 6 ... a(n) => (n)*(n+1)/2

    16 = 10 + 6 => aaaaa bbbb 12 = 10 + 1 + 1 => aaaaa bb cc

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

    First, we'll find the minimum accumulative cost of a string. In fact, we will prove something more: the accumulative cost of a string doesn't depend on the order they are combined.

    Imagine that between every pair of identical letters, we have a tune. Thus for example, in the example string abababab, each pair of a's have a tune between them, and so as each pair of b's. That's a total of 12 tunes. We claim that the accumulative cost is simply the sum of all tunes.

    To do so, we will remove a tune at the moment that the pair of letters are merged into the same string. For example, when we merge aba and ac, the two pairs of a's (pick either a in aba, and pick the a in ac) will lose their tunes (the pair of a's formed by taking both a's in aba has already lost its tune). It's obvious that each tune is removed exactly once, since at the beginning no letter is in a string with any other letter, and at the end every letter is in the same string. It remains to show that each tune does contribute exactly 1 to the accumulative cost.

    Consider f(s, c) × f(t, c). Look at each occurrence of the character c in s, and another occurrence of the character c in t. They have a tune between them (because they haven't been merged). There are f(s, c) × f(t, c) ways to pick this pair of c's, and so f(s, c) × f(t, c) tunes as well. All these tunes will be lost when they are merged, and it costs the same amount to merge them. Summing over all c proves the claim.


    Now that we have shown that we can compute the minimum accumulation cost of a string from just counting how many times each character appears. If there are n of a character, then they have tunes among them; simply sum over all characters to obtain the accumulation cost.

    Now, constructing a string is easy. Just take n as large as possible while keeping ; now we have n a's. Subtract k by and set that as the new value of k. Take n as large as possible again; we have n b's. Repeat until we're done. For k ≤ 100000, it can be proven that this greedy strategy works (it's impossible to have k > 0 after using all 26 letters).

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

Problem C is shit: simple idea, but difficult implementation. And with TL like this it's not obvious what will/will not pass...

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

WTF, it was?

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

Am I the only one who was stuck on div2 A for a very long time?

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

In 2C cannot we do it as {1,3,6,10,15,21...} and find n as a sum of elements of this set?

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

please help me :( my code got MLE on first test (D div2) but I didnt use much memory on it.

http://codeforces.me/contest/849/submission/29990097

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

Harder round than usual.

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

How to solve Div2(B)? Any ideas?

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

Is there an easy solution for C? I came up with a that I can't finish coding in 30 minutes (probably 200 lines of code).

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

    Hope my solution doesn't FST...(upd: Passed System Test!)

    For any two points i, j that ai = aj, if there doesn't exist i < k < j that ai = ak, then we create an interval [i, j]. The query just asks the sum of lengths of all intervals that lie in [l, r], and update changes O(1) intervals.

    Let's take an interval [l, r] as a point (l, r) on the 2D plane, and its weight is r - l. A query [l, r] asks about the sum of weights of all points (x, y) that l ≤ x, y ≤ r.

    You can write a DS that supports add/delete 2D points and 2D rectangle sum query. I used Fenwick tree + balanced search tree. The time complexity is and space complexity is .

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

    As long as you know how to code 2d segment trees, it is. Consider the points of coordinates (prev[i], i) with values i — prev[i]. In one query (L, R), you're interested in the sum of the values of the points with L <= x and y <= R. When you modify a value, at most 3 prevs change

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

    90 lines only 29981295

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

Am I the only one who took 20 minutes in C to avoid using map with 2d fenwick tree (and didn't succeed)? I had a solution involving any sort of 2d segment tree and didn't know how to properly code it (I though of offline solution that would normalize stuff), but any implementation has, besides the log^2 complexity and extra log or pretty big constant (maybe if we use instead of map some better hash). So, I wasted time and got nervous, but at least I can learn something out of this experience. Can anybody tell me how to properly code 2d segment trees so that you don't need an extra log or hash to access memory spaces? I do know how to do that with a segment tree with binary search trees (treaps more precisely) in nodes, but that is neither elegant, nor constant-friendly:))any help?

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

    fenwick tree is superfast and it was likely that it would get accepted (and it did :)))) btw, even n sqrt log with fenwick gets accepted here
    so i think there was no reason to get nervous as TL was pretty big

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

Is int32 (int in C++) enough for problem B div 2 ?

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

Why div 2 B ? ...

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

My first div1 contest and i think i'm going back to div2(((

»
9 лет назад, скрыть # |
 
Проголосовать: нравится +35 Проголосовать: не нравится
  1. Stare at a problem A for 10 minutes.
  2. Write dp solution.
  3. Check whether I turned up in Div1 by accident.
»
9 лет назад, скрыть # |
 
Проголосовать: нравится +73 Проголосовать: не нравится

Failed on tests 5 6 7 8 9

Image and video hosting by TinyPic

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

Hacks for Div. 2 A and B?

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

ODDS&ENDS by. supercell ( ryo )

Tell Your World by. 8 Prince

From Y to Y by. OneRoom

Rooter's Song by. DECO*27

Goodbye Souvenir by. Toa

Miku is the best.

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

Am I the only one who found Div2 C easier than Div2 A and Div2 B??? :|

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

I think div1C can be solved in this way in O(nlogn) but I suck at implementing it — spent 90 mins and got nothing. :(

The answer of each query is equal to the accumulated value of nxt[i]-i for l <= i <= r where nxt[i] is the smallest value which satisfies a[nxt[i]] == a[i]. (Let nxt[i] = n if there is no candidate for the sake of implementation), minus nxt[i]-i the rightmost elements of each values

nxt[i]-i can be maintained with a trivial fenwick tree.

Denote red[i] to be the sum of values to be reduced for queries [l,r] where r == i, this value could also be maintained with any range structure. (Just increment red[i..nxt[i]] by nxt-i)

My buggy code for the brief idea: https://ideone.com/NPDI0p

Edit: Nvm, I think it fails to handle elements which are not contained within the query range

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

It feels good when System Testing is so fast =P =D

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

Super fast system test! Great!

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

It seems that there are many solutions and complexities in Div.1 C.

Which complexity did you use?

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

I have an impression that when score distribution is like "x-y-1750-1750-z" or "x-y-z-2250-2250" it almost always turns out it would have been better to have standard one. Like this contest or here: http://codeforces.me/contest/830

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

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

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

A moment of silence for those who solved A then jumped to C but couldn't finish debugging it on time :(

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

When ur python code can't perform 1e6 operations in 2s and gives TLE :(

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

I must say, extremely bad problemset. Would require one hell of a disinterested person to write such bad problems.

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

EDIT: The editorial is already up, wow. Well, I'll leave it here anyway.

I didn't come up with a complete solution for Div1D, but this is my idea:

For convenience, suppose a change involves the edge (u, v), and vertex w and edges (u, w), (w, v) are added. Then we say w is built on top of (u, v). We also say (u, w), (w, v) are children of (u, v). We say (x, y) is a descendant of (u, v) if (x, y) is a child of a child of ... of a child of (u, v) (with any positive number of levels). Let cut(u, v) be the minimum (u, v)-cut in the subgraph made of (u, v) and its descendants, minus 1 (the edge (u, v) itself). This minus one make things much cleaner.

First, suppose u1, u2, u3, ..., up are all the vertices built on top of (s, t). Then ; this can easily be proven by induction (and the base case itself is easy to see: either you cut from s to u1, or cut u1 to t).

Given this, we can use dynamic programming to solve it. An attempt is to set dp[n][m] to be the number of possible worlds where there are n changes and cut(s, t) = m. (Since we don't count (s, t) itself in cut(s, t), given input n, m our answer is dp[n][m - 1].) If we could somehow take care of the similarity condition, this would work:

  • Fix p (the number of vertices built on top of (s, t)).
  • Fix n'1, n'2, ..., n'p, n"1, n"2, ..., n"p: n'i denotes the number of changes made on top of (s, ui) or a descendant of it, and n"i denotes the number of changes made on top of (ui, t) or a descendant of it. The condition is that (n'i + n"i) = n - p (we already made p changes, u1, u2, ..., up).
  • Fix m'1, m'2, ..., m'p, m"1, m"2, ..., m"p: m'i = cut(s, ui), and m"i = cut(ui, t). The condition is that min {m'i, m"i} = m - p.
  • The base case is dp[0][0] = 1 (no change needed), dp[n][0] = 0 for n ≥ 1 (we may not make any cut, but we must make some change), and dp[0][m] = 0 for m ≥ 1 (we cannot make any change, but we must add a cut).
  • Compute (dp[n'i][m'i] × dp[n"i][m"i]).
  • Iterate over all possible values of them and sum it all. (Take modulo 109 + 7.)

The similarity condition makes things hard, however, since we need to take care not to count the same thing twice. As an example, suppose n'1 = n'2, n"1 = n"2, m'1 = m'2, m"1 = m"2, and yet the subgraph built on top of (s, u1) or its descendant, say H, and the subgraph built on top of (s, u2) or its descendant, say H', are different. Then we will get another valid graph by swapping H and H'. This gives the same graph, but our naive DP algorithm will count them as different. So we need to take care of that.

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

My solutions for the problem is perfectly okay but they were rejected during the contest for no reason.
Look at the two solutions below 2991746, 29991714 the only different is at line 153.
Everything is exactly the same. Even the output is same.
Can anybody explain?

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

Nice problems!

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

super contest !!!

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

I got AC on Div. 1 D after contest (I couldn't get it to pass during contest because I wasted time on Div. 1 C). Here's my solution :

Let dp[i][j][k] denote the number of distinct graphs that can be formed after applying the operation i times so that the max flow is j, and k is something we will describe later. We iterate through x, the number of times we use the edge s-e to construct a new vertex where k flow will flow through it. Iterate through y, the total number of operations spent on this part of the graph (the current edges and all the edges that will occur after it). We need to find the number of ways to use y operations to create x pairs of graphs of the same type such that for each pair of graphs (A, B), the minimum of max flow of A and the max flow of B is exactly k. Suppose we know the answer to this is X. Then, we can increment dp[i - x - y][j - kx][min(j - kx, k - 1)]·X to dp[i][j][k].

Let dp2[i][j] denote the number of ordered pairs of graphs (A, B) we can form such that the minimum of max flow of A and the max flow of B is exactly j and a total of i operations are used. Then, we can iterate through all k, denoting that we use k operations to form A, and all pairs (l, m) with min(l, m) = j and add dp[k][l][l]·dp[i - k][m][m] to dp2[i][j].

Finally, let dp3[i][j][k][mx] denote the number of multisets of ordered pairs of graphs (A, B) we can form such that the minimum of max flow of A and the max flow of B is exactly j and a total of i operations are used, assuming that we can only use at most mx operations for each pair of graphs. Iterate through l, the number of pairs where we use exactly mx operations. Let C = dp2[mx][j]. There are C ways to choose one pair, and we need to choose l pairs, possibly with repetitions. The number of ways to do this is by the balls in urns formula, and this value can be computed in O(n) time since l ≤ n. Thus, we add to dp3[i][j][k][mx]. We can use the value of dp3 to find the X we need for dp above.

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

I know Div1C N * sqrt(N) solution but I did not have time to finish writing it :( Offensively

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

WTF!!

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

All my solutions were "skipped" and I was not given a contest rank.I did not plagiarize any code from anyone ....

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

Bad luck. Solution for A and C was correct. If these two got rated then.... Alas! they got skipped.

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

Nice problems!

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

can someone tell,why WA it's working for the same input on ideone — http://codeforces.me/contest/849/submission/29996525

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

thank you ♂sir

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

昨晚有点崩,本人hack了,以后一定要稳定心态,加油!

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

Dongda District so many people want to play codeforces, but only the middle of the night to play, hoping to like that last night that time, or later can, or every time the second day of class are listless.

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

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