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

Автор IceKnight1093, история, 4 месяца назад, По-английски

We invite you to participate in CodeChef’s Starters 117, this Wednesday, 17th January, rated for till 5-Stars (ie. for users with rating < 2200).

Time: 8:00 PM — 10:00 PM IST

Joining us on the problem setting panel are:

Written editorials will be available for all on discuss.codechef.com. Pro users can find the editorials directly on the problem pages after the contest. The video editorials of the problems will be available only to Pro users.

Also, if you have some original and engaging problem ideas, and you’re interested in them being used in CodeChef's contests, you can share them here.

Hope to see you participating.

Good Luck!

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

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

EQUAL2 and A and B are very similar. Other questions were good though.Thanks for the contest.

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

Thanks for yet Another observe the pattern , find corner cases and code it using if else if else :D !

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

How to implement sting strings?

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

    Just simulate what was written in the question. Each time someone plays at least 1 character will get deleted, so there will be at most n games for each string.

    I used a stack to simulate the game. You can check the code below

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

It seems that the test-cases for the STINGY ARRAYS Question are very weak. O(N^2) brute force solutions ACs all the test cases.

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

Can anyone help me to find the solution for problem EQUAL2.

I observed that for difference of A and B is equal X [X = abs(A-B)], let the answer will be Y. Here is a chart,

X = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]

Y = [0, 1, 3, 2, 3, 5, 3, 5, 4, 5, 4, 5, 7, 5, 7, 6, 7, 6, 7, 6, 7, 9, 7, 9, 7]

I can't solve this pattern for any difference n. If anyone have free time, please discuss the solution.

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

    https://www.codechef.com/viewsolution/1040425909

    Here is the code for EQUAL2 problem

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

      Can you explain why you multiply your abs(n — m) with 8?

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

        If abs(n-m)=10 , take the sqrt of that 8*abs(n-m) gives 8 and add 1 and divide by 2 gives 4. (10 can be expressed by atleast 4 consecutive numbers, 1+2+3+4=10)

        If abs(n-m)=11 , take the sqrt of that 8*abs(n-m) gives 9 and add 1 and divide by 2 gives 5. (11 cannot be expressed by 4 consecutive numbers. It should be expressed by atleast 5 consecutive numbers, 1-2+3+4+5=11)

        By Logic, If abs(n-m) is odd then ans will be expressed as (k%4==1 or k%4==2) consecutive numbers . Else if abs(n-m) is even then ans will be expressed as (k%4==3 or k%4==0) consecutive numbers where k is an integer.

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

Can anyone please have a look at my code for today's CodeChef Stingy Arrays problem.
I tried doing stress testing, but couldn't find the failing test case; maybe its an edge case.