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

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

Hello Codeforces community,

I would like to invite you to join HackerRank's 101 Hack 50 on June 20, 2017.

There will be five tasks and three hours for you to solve them. The contest will be rated and the top ten contestants will receive HackerRank T-shirts!

The problems are prepared by kevinsogo, nabila_ahmed, zemen, fedimser, and krismaz and tested by shashank21j, allllekssssa, bayleef, wanbo, and kevinsogo. I hope you'll enjoy the problems prepared by the community!

Happy Coding!

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

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

And I planned to do round :D

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

just curious, when world codesprint 12 will be shown in contests??

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

How to solve C efficiently . I tried to brute force using string hashing . But I wasn't able to implement it in time . Anyways it would run in O(N3).

I don't want to spoil the solution by seeing the editorial , can someone give some hints.

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

I got lucky... For D: Frog in Maze, I knew the solution was going to be

[intended solution]

but somehow I could use

[some other trick]

to simulate DP 2^20 rounds, squeezing within the time limit (1.95s/2s), and pass all the test cases. Also, simulating only ~10^4 rounds already gave me 60.51/65 points.

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

    Hey, can u plz explain ur solution using matrix powers? Also by simulating rounds, u mean to intialize exits by 1, rest by 0, and iterate over all about 10^4 no. of times, right?

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

      (Never mind the spoiler tag then.)

      1. Compute the transition probabilities X (i.e., X[p1][p2]: if you're at p1, what's the probability that you'll end up at p2 in one step). Nothing enters the obstacles or leaves the mines or exits.

      2. Compute Y = X^N (for some large N). Y[p1][p2] would be the probability that you'll end up at p2 after moving N steps from p1, including getting stuck at p2.

      3. Sum Y[start][exit] for all exit cells '%'.

      This method is only an approximation, but I was surprised it was good enough.

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

    Makes sense that it would work. The matrix equation to solve is (E - T)p = v, where E is the unit matrix and p are probabilities; informally, (geometric series), you're simulating just the first x terms. As long as all eigenvalues of T are less than 1 in abs. value, Tk should converge to the zero matrix (about as fast as ).