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

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

Hello, everyone!

I want to invite you to participate in May Medium Contest at HackerEarth — which is called May Hem. The Contest is scheduled on 30th May. The duration of the contest is 2 hours. It's a play on a word that denotes chaos — hopefully, in a good way for this contest.

So, go for it, give it your best shot! There are amazing prizes to be won!

Link to the contest: http://hck.re/sUY9S1

sentinel45 is author and editorialist of this problemset, while lamphanviet is the tester for this contest.

Top 5 of leaderboard will also receive prizes:

$50 Amazon gift card + HackerEarth T-shirt
$30 Amazon gift card + HackerEarth T-shirt
$20 Amazon gift card + HackerEarth T-shirt
HackerEarth T-shirt
HackerEarth T-shirt

Good luck, everyone! :)

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

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

I think that I hacked some of the tests for the second problem and I got full score:

Solution for 88 points: http://ideone.com/cnRd5p

Solution for 100 points: http://ideone.com/mAceb4

The only difference is in line 65:

88 points:

for(cnt=1;cnt<=n;cnt++,idx1=next(idx1),idx2=next(idx2))

100 points:

for(cnt=1;cnt<=min(n,1000);cnt++,idx1=next(idx1),idx2=next(idx2))

Anybody else who did the same? xD

BTW, how to solve the first and the second problem. For the second, I can find the maximum number of inversions fast but I don't know how to find the index fast.

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

    You can read other solutions now.

    For first problem, I used binary search to move to how many wavy numbers do not exceed N?, and this new task can be solved with pretty standard DP, where we build number digit by digit and store all required information as parameters of DP (current position, last digit, current direction, is our number already less than N).

    For second problem, I wrote down initial array two times and then counted inversions for all subarrays of size N (sliding window works well). Comparing two substrings fast is a very well-known problem with a lot of possible solutions — my choise was hashing.

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

      I ran over your solutions and I understood them, thank you for the additional explanation :) And congratulations for the place you took! :)

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

        Thanks :)

        Starting time of a contest was very uncomfortable today. I had a hard choice between writing a maxflow on GCJ and switching to HE contest; looking at standings now, I think that choice I made was right — with horrible performance I still managed to beat much stronger contestants, and was close to winning a contest — only because I started eariler. And I wasn't going to qualify for onsite at GCJ anyway, even in case I passed to the next round :)

        I think that in future HE admins should set contest time in such a way that overlapping with other big contests is avoided. In this case it will attract more strong contestants. Usually it isn't hard to find a slot for 2h-long contest.

        Anyway, I can't miss a contest named after Norwegian black metal band. Or after American music festival, I am not sure...