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

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

Hello CodeForces Community!

The monthly programming action takes the centre stage once again after SnackDown 2016 Finale. I hope you all are ready to get back to your weekly dose of programming. So, let’s start.

I’d like to invite you to the CodeChef July CookOff 2016 CodeChef July Cook-Off. This time, the Cook-Off will happen as per its usual time i.e., on the second last Sunday of the month. Joining me on the problem setting panel are:

  • Problem Setter: mgch (Misha Chorniy)

  • Problem Tester: karanaggarwal ( Karan Aggarwal)

  • Editorialist: pushkarmishra (Pushkar Mishra)

  • Russian Translator: CherryTree (Sergey Kulik)

  • Mandarin Translator: huzecong (Hu Zecong)

  • Vietnamese Translator: VNOI Team

  • Contest Admin and Language Verifier: PraveenDhinwa (Praveen Dhinwa)

I hope you will enjoy solving them. Please give your feedback on the problem set in the comments below after the contest. You can find the rest of the details about the contest below.

Time: 24th July 2016 (2130 hrs) to 25th July 2016 (0000 hrs). (Indian Standard Time — +5:30 GMT) — Check your timezone.

Details: https://www.codechef.com/COOK72

Registration: You just need to have a CodeChef handle to participate. For all those, who are interested and do not have a CodeChef handle, are requested to register in order to participate.

Prizes:

  • Top 10 performers in Global and Indian category will get CodeChef laddus, with which the winners can claim cool CodeChef goodies. Know more here: https://www.codechef.com/laddu. (For those who have not yet got their previous winning, please send an email to [email protected])
  • Проголосовать: нравится
  • +50
  • Проголосовать: не нравится

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

When will the laddu system start ? It's been months -_- .

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

Reminder, contest just started !!

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

How to solve Chef and Sort?

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

I'm surprised the last problem wasn't solved more often.

An expected value problem like this one is clearly solved by finding linear formulas for expected values of some states.

In this case, the states should be cycle lengths, since a swap either merges 2 cycles or splits a cycle into two. The order of cycle lengths doesn't matter, which reduces the number of possible states to S = 42 for N = 10. We can find them by some optimised backtracking and map arrays of cycle lengths to integers in O(S4).

The rest is just computing the number of ways to go from any state to any other — again in O(S4) and GEM in O(S3) to find the expected values. The time complexity should be something like O(S4) with a good constant.

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

Solution for Chef Land by romanova:-
Update : Even the tester's solution is random output :D
Update : Fixed username xD
Update : This just keeps getting better and better. The same solution when resubmitted in practice gives WA ----> Link

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

    is a counter case for this even possible?

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

      Apparently it is about some luck as well — as you can see, there is 15% chance to not even reach the end s-shaped path when starting from its beginning and doing this kind of random walk for 1e5 moves.

      Can anybody tell me how to calculate chance to pass such figure from all positions? The fact that string is good for starting from first position doesn't mean it is good for reaching finish from second cell of s-shaped labyrinth, but I have no idea how to find probability of random string being good for all possible starting positions in given labyrinth at the same time.

      Just in case, I mean something like this:

      ####################
      #C.................#
      ##################.#
      #..................#
      #.##################
      #..................#
      ##################.#
      #..................#
      #.##################
      #..................#
      ##################.#
      #..................#
      #.##################
      #..................#
      ##################.#
      #..................#
      #.##################
      #..................#
      ##################.#
      ####################
      

      And even this particular case can be made harder with some small modifications.

      Upd. And now I think I had some bugs while considering pairs/groups of cells, because after some thinking if looks like for this particular map starting from 2nd cell is strictly better than starting from 1st — in case you can reach finish from 1st cell, you can make it from 2nd as well, as first path can't simply outrun second somehow.

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

    Embed related.

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

    I was curious why nobody is solving it instantly, and also it sounded like expected hitting time for worst case is rather high (O(N^2) for a line of length N, right?), so I started to code other problem instead, and even after seeing AC solutions on this problem I decided to add while(true) with checker there :)

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

      My solution is even worse. Atleast you are printing 105 characters, I'm just printing any arbitrary dfs tree with the root of the dfs as the capital city — The length of the answer string is  < 2 * N * M.

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

    When you solve a problem in a nice way and your boyfriend gets all the credit (see rev. 4).

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

I used a simple approach which guaranteed to give a solution which satisfy given constrain but i am not able to prove char constrain. Let say you have string 'ans' which stores char sequence. From any cell having '.' , first traverse the 'ans'. If during traversal if it passes through the capital city then no string need to append to 'ans' but if it will not pass then keep the last position of cell after traversal through current 'ans'. Then do a simple dfs from last position to capital city and append this path to our current 'ans'.

code