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

Автор muratt, 8 лет назад, По-английски

Hello Codeforces!

I am glad to invite you all to participate in regular Codeforces Round #352 that will take place on 11 May, 19:35 MSK. This will be my first round, so I hope that it will be interesting for you guys. There will be 5 problems for each division, and contest will last 2 hours.

Round wouldn't take place without the help of GlebsHP, I am very thankful for his great help. I also want to thank to Zlobober, winger, AlexFetisov, ikbal and ykaya for testing problems, to hasanb for inspiring me in a problem. I got great help and wise advices from all of them so this is their round too as much as mine. Of course I want to thank Mike and all others who puts his effort into Codeforces and Polygon systems. I don't know what we would do without this great platform.

UPD1: Score distribution:

Div. 2: 500-1000-1500-2000-2500

Div. 1: 500-1000-1500-2000-3000

UPD2: I will post editorial as soon as possible, thank you for your patience. Congratulations to winners!

Div.1 winners:

1-subscriber

2-W4yneb0t

3-jcvb

4-Merkurev

5--XraY-

Div.2 winners:

1-the_arr_of_war

2-Shavkat_Aminov

3-Lightning34

4-I_Love_Ginger

5-tjandra

UPD3: Editorial is now available.

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

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

is it rated?

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

I have piano lessons on Sundays and Wednesdays at 07:30. 99% of CF rounds are on Sundays or Wednesdays at 07:30. I'm so unlucky!!

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

Good luck and have fun!

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

I guess it's first Turkish round

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

Hope to see interesting problems and good luck to everyone!

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

Asin bayraklari!

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

.

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

And also thanks to me, who prepared the meals for contest team.

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

I hope, that statements will be short like this blog.

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

It is also first turkish round in CF =)

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

" As they told me round will be rated, but don't be hesitated to ask again for just to be sure. "

ok , is it rated ?

joke apart , good luck and have fun :)

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

How Long Does this Contest take ?

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

This contest will be very exciting. I hope i will be successful.

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

NE MUTLU TURKUM DIYENE !!!!

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

i m looking forward to join contest

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

I am seriously considering join the contest.

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

A Regular codeforces round these do happen every once in a while now don't they nevertheless i hope it's fun ^_^

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

А условие на русском будет или нет?

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

Why is my registration canceled automatically? So is it with jqdai0815.

UPD:It says 522 people have registered, but when I clicked into the page to see the registrants, I only saw 300+ people.

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

I am back

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

Beresta ready for another crossover? Coz I am.

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

24 minutes to go! best site <3 love you codeforces! <3

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

Sa beyler

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

Good luck everyone ... Try to do your best!

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

I don't like "WA"...

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

    I believe TLE is worst, because you probably need to write a completely different algorithm to get AC, whereas in the case of a WA, you may find a bug quickly and then solve the problem.

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

> Долго ждать задачу про кек и Кекляндию
> Слить раунд

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

Can someone give me a hit to solve DIV2.D?

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

The score distribution for Div.1 today should be 250-250-30000-30000-30000 :P

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

Did pretests for Div1 D really not have a test for n == 1?

I had a solution that printed -1 in such case instead of 0, but, luckily, fixed it.

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

Passed pretest of Div2C after ages but I know it's gonna fail.

Testcase

0 1 0 2 0 0

1

0 3

Answer — 4

I am going cry in the corner of my bathroom. ;(

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

Such interesting contest, so many problems were solved by everyone

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

Can anybody talk about how they did Div1C?

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

Worst feeling in the world: "Contest finished reload page" while pressing the submit button (no it didn't count)

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

    Even worse feeling, when you submit that solution after the contest and it says

    "ALL TESTS PASSED"

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

      That would be a mixed feeling between "man I'm awesome" and "f*** this **%* ** 12#$* @!#*!@% !*@#( #@!"

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

I hate it when I finish my solution to Div2 C literally seconds after the finish of the contest!!!. Also, it seems I haven't read the statement carefully, which is the reason why I started that late.

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

How to solve DIV2D?

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

    Binary search the maximum height after removing k blocks, then binary search the minimum depth you can fill with k blocks. More or less.

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

    Let's see if it passes the tests, but I just sorted the list and then searched from each end until I reached a value that was on the other side of the average (if I did this the difference was 0 or 1 depending on whether sum%n == 0) or you've removed too many blocks already, and then max-min

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

    My solution is not using binary search. I am calculating final number where highest and lowest number end after k days, if they cross over answer is 0 or 1. 0 when total sum can be evenly distributed among n numbers, 1 otherwise.

    For calculating final number where current highest ends, I keep on jumping to smaller non 1 frequency number if k is enough, else use up all of k and end up somewhere in middle (0 frequency number, this is breaking condition and at max happens only once). Maximum O(n) traverse.

    Similarly calculated final state where lowest number end.

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

как в A(Div1)/C(Div2) получились такие ответы во входных тестах? Я написал решение, а оно выдает на 1.6-1.8 больше. Это же не может быть проблема с погрешностью?

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

I'm starting to hate CF rating system; I don't think that fast solving first 2 problems and hacking a few other contestants really deserves a +130 rating change in Div1.

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

    I hate hacking too :)) but I have to admit that understanding someone's code in such a relatively short time is really an admirable skill. Besides, it also helps careless coders realise their mistake. So, it is worth awarding.

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

    The thing is that when you have a lot of people and only 5 problems, it's really hard to judge how well you perform (unless you performed exceptionally good/bad) so even though at times it might seem unfair, in the long run it is fair. And it really doesn't matter what kind of judgement system you use there will always be someone that will think it's unfair.

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

Does binary search work for Div2D?

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

    I did two binary searches one for best low value and one for best hi value. I think a ternary search will also work. Do not have the approach though.

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

What was pretest 3 for Div2 C ?

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

Most complicated solution I could see for Div 2 A
http://codeforces.com/contest/672/submission/17850982

Please share, if anyone get idea behind it :D

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

How do you solve Div-2C ? Anyone. Thanks.

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

    Dynamic Programming..

    state (index,adil,bera)

    100000*2*2

    adil and bera represent if they went first time or not..after that both start at bin cycle so no problem

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

    Lets us consider there is only person.

    After picking a bottle and throwing it in bin, then for all other bottles distances will be 2 * distance of that bottle from origin because you will start and end at origin after throwing each bottle. So first of all calculate sum of distance of all bottles and multiply it by 2.

    Then find the bottle which at has this value minimum (distance of bottle from person — distance of person from origin). Add this to answer.

    For two people, you can think of it in a similar way.

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

    I solved it greedy...

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

    Notice, that when Adil or Bera get to the recycling bin, they always walk the path to the bottle twice (it doesn't matter who is gathering bottles after the first recycled bottle).

    That is, imagine these are distances from bottles to the recycling bin:
    distFromBottleToBin[0] = ...
    distFromBottleToBin[1] = ...
    ...
    distFromBottleToBin[n - 1] = ...

    If Adil or Bera started standing right on the bottles i and j, the total distance would be:
    distFromBottleToBin[0] + 
    distFromBottleToBin[1] + ... + 
    1 ·distFromBottleToBin[i] + ... + 
    1 ·distFromBottleToBin[j] + ... + 
    distFromBottleToBin[n - 1].

    Since they are not standing on them you should add up additional cost of traveling to the i'th and j'th (closest to them) bottles:
    distFromBottleToBin[i] + distFromAdilToBottle[i] + 
    distFromBottleToBin[j] + distFromBeraToBottle[j]

    Notice also that if Adil and Bera are further from all the bottles than the recycling bin, then we have to choose the closest bottle to either one of them and one of them will be doing nothing.

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

When you solve E ~5 mins after contest T_T

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

Oh My God!!! I got bluescreen before 5 minute the end!!!

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

I am unluckiest person trying to hack the luckiest person !!!

check the return statement

code: 17850999

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

When would Editorial be published?

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

I was one semicolon away from finishing Div2C.

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

How can i increase my efficiency and accuracy in contests?

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

    study?

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

    Well, maybe not the best way to do it, but you can just participate in contests, read editorials and implement solutions. Also for div1 problems, if you feel ok with it.

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

How to solve C,div2 ? My idea was to sort the coordonates of objects and after that answer would be : ans += min (A,B),where A=Distance from Adil to recycling bin through bottle i and B from Bera.(for i=1, to n). But how to sort them ? I think that only the first two are important, 'cause after recycling one bottle, the coordonates of character will be changed to r0,r1.In this case , first element should be the closest bottle to Adil , the second the closest bottle to Bera(but the disstance from r0,r1 to it should be longer than from Bera to r0,r1); Is good this solution or not ?

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

Can some one give me the ideal path for div2-c sample test 2? I just can't figure it out...please.

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

I screwed up but I enjoyed div1-ABC a lot. Nice problems with fine difficulty. Keep my upvote muratt.

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

When I saw " all ints starting from 1" I thought it meant...18 19 100 101 102...you know like all the ints starting WITH 1 I guess that's why I get stuck on gray but still it was a great round hope there will be more soon so I can return to green again :)

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

Hated today's Div2 C so much. Wasted a lot of time trying to implement it in the first place, and then to overcome WA 8 (without succeeding); I wish I had spent that time on problem D.

The worst thing is that the approach to solve the problem was actually pretty much straightforward, but implementing it and taking all cases into consideration turned out to be very, very time-consuming.

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

System testing isn't over yet and it is like

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

Weak tests! this AC code fails on test 0 1 0 2 0 0 1 0 3 muratt can you take a look please.

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

Can anyone tell me how he solved div1D? I really liked the task, but didn't have any idea how to solve it.

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

Test case 25. xD

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

Resubmitted C at final moment and got AC. Nice problems, my upvote for you muratt

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

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

Div2 C WA on test 80 :(

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

When your D gives less points than your B :D

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

why am i getting wrong answer ?!

17852756

thanks!

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

56 more submissions and I would have made it :(

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

Whats the reason for wa @ test 25

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

Hey Guys, here is my code for div2-c . Can some body please help me?

What I do is 1>1st consider that either person A and B collect all bottles..

2> Consider point i to be starting point for person A. Then consider all points except point i to be starting point for person B. Now calcualte the sum of all these distance and check if it is minimum...

Did i Miss any case???

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

    I didn't read your code. But your idea is O(n^2) right? For each point you check all other points. This was my innitial idea too, but there is a way to solve it in O(n), it's very similar to your idea, you just have to think a bit more.

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

      I acutally created a segment tree for person A, and then iterated over distance of person B, combined their sum and checked the answer...There should be no problem with the Time complexity, I have missed some case or made some mistake...

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

when will tutorial be published?

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

Had a silly mistake in Div 2 B. Surprised (and sad), no one hacked this during contest :o :(

//data refers to map of characters in string
if (data.size() == 26)
{
    cout << -1;
}
»
8 лет назад, # |
  Проголосовать: нравится +5 Проголосовать: не нравится

How to solve div2 D?

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

Nice problems, but I'd prefer C to be easier to implement, especially because D needs quite a long code too.

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

    Actually my codes are ~100 lines for both. But as i see there are some quite long solutions.

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

What is the correct answer for this test to Div1 A?

100 0 0 100 0 0
2
0 1
1 0

My program returns 102 and I have been hacked with it.

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

    102

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

    My program returns 102 too and i got accepted in main tests

    EDIT : solving by hand, answer is clearly 102, so we are both correct

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

    OK, my program returns diffrent valuess running in Dev C++ and in online compiler so it's my mistake. Thanks.

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

    According to your first hack based on previous code :-

    The details of that hack

    wrong answer 1st numbers differ — expected: '102.0000000', found: '200.0000000', error = '0.9607843'

    Input: 100 0 0 100 0 0 2 0 1 1 0

    Output: 200.0000000000

    Answer: 102.000000000000

    Time: 0

    Memory: 4489216

    [close]

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

Thanks for quickly system test and hopefully rating should be updated quickly.

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

Thanks
contest was good.

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

del

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

o.O

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

Can anyone please explain how to solve Div 1 D? I thought in the lines of HLD + DP, but couldn't find the correct approach.

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

    I wasn't able to find any solution. I guess that once you solved the DP in N^2 or N^3 or something like that, the optimizations are not the big problem. What DP did you try to use?

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

      I tried to do dp(v) and then for each worker that has a path u -> v, I tried adding that cost plus dp(u), plus dp(i) for all children i of v that don't lie in the path from u to v, but then I realized that I'm missing a lot of paths that way. Then I tried a few more variations, without success.

      In the end, I couldn't find anything. The problem is that you pay each worker only once. If the cost of a worker was per road, then the problem would be easy. RMQ after HLD would solve it. Perhaps even a carefully implemented DFS + multiset would work, I don't know.

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

        My solution is a lot like your solution. In stead of going u to v, we can use all paths u to k where k is in the path between u and v with same cost c. Then in optimal paths will not intersect. So we can calculate answer for all nodes subtrees. We will use segment tree contructed by workers. Each leaf will keep the value you said above, we can easily update them when we go to current node s parent. You can see detailed solution when editorial published.

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

The first and second places at Div2 from Uzbekistan. Go, go, go Uzbekistan!

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

I finished problem C in the last few minutes and now I have become an IGM! Thanks for the nice problems though I think C should be worth more points.

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

What about the editorial?

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

Nice problemset, thank you muratt :)

btw, why div_2 E problem only worth 2500 pts, not 3000 pts? imho the difficulty on div_2 E is far greater than div_2 D, maybe the author have some magic easy solution (?) i don't know.. waiting for editorials :)

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

In problem div2 C

why this submission 17859797 gets RTE?!!

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

    Your comparison operator is incorrect. Yeah, copypaste sucks:

    bool cmpA(po a,po b){
      return a.disZ-a.disA>b.disZ-b.disB; // Should be disA
    }
    
»
8 лет назад, # |
Rev. 2   Проголосовать: нравится +7 Проголосовать: не нравится

I think that Div1D is very good and interesting problem!!

First, I thought this problem need heavy data structure(ex. HL Decomposition, Link-cut Tree ....), but this problem need only segment tree with range add/min.

And I came back to redcoder! Thanks for this nice problem set.

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

Может , кто нибудь напишет на русском языке суть решения задачи — Мусор на переработку. Как здесь надо оптимально действовать, чтобы получить минимальный путь обхода? Спасибо.

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

    Обозначим за T удвоенную сумму расстояний от каждой бутылки до мусорки. Теперь заметим, что наш ответ зависит только от того, какую бутылку первой возьмёт Ашот и какую первой возьмёт Бера(случаи когда собирает бутылки только один из них можете рассмотреть аналогично самостоятельно). Тогда, для двух двух бутылок i и j ответ считается по формуле T + dist(a, i) — dist(c, i) + dist(b, j) — dist(c, j). Теперь нам надо найти минимальное такое значение. Если перебрать i и j, то будет корректное решение за O(n^2). Но нам надо быстрее. Тогда обозначим f1(i) = dist(a, i) — dist(c, i) а f2(i) = dist(b, i) — dist(c, i) Тогда формула сверху прекращается в T + f1(i) + f2(j). Очевидно, ее что значение минимально при минимальном значение f1(i) + f2(j). Ну а это уже совсем другая задача. Её можно решить с помощью sparce table(честно), а можно заметить, что ответ — это минимум по f1 + минимум по f2 если они не являются одной бутылкой и минимум по f1 + второй минимум по f2 или наоборот если первые минимумы достигаются в одной бутылке. Получается O(n) решение.

    Мне показалось, что оно сложновато для div2c, поэтому я весь контест придумывал жадник... Возможно, что его просто нет.

    Всмысле, жадник, конечно, есть, я его, в общем то и описал, просто его на плоскости никак не представить.

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

Can Somebody help me about my solution ? 17880268 When i compile at my pc, it prints correct answer (at least for given examples). it doesn't print 0.000... like here. Thanks !