IceKnight1093's blog

By IceKnight1093, history, 11 months ago, In English

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!

  • Vote: I like it
  • +33
  • Vote: I do not like it

»
11 months ago, # |
  Vote: I like it +13 Vote: I do not like it

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

»
11 months ago, # |
  Vote: I like it +10 Vote: I do not like it

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

»
11 months ago, # |
  Vote: I like it 0 Vote: I do not like it

How to implement sting strings?

  • »
    »
    11 months ago, # ^ |
    Rev. 2   Vote: I like it +6 Vote: I do not like it

    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
»
11 months ago, # |
Rev. 2   Vote: I like it +8 Vote: I do not like it

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.

»
11 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

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.

  • »
    »
    11 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

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

    Here is the code for EQUAL2 problem

    • »
      »
      »
      11 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

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

      • »
        »
        »
        »
        11 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        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.

»
11 months ago, # |
  Vote: I like it 0 Vote: I do not like it

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.

  • »
    »
    11 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    explain urs approch .

  • »
    »
    11 months ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    1

    30

    2 4 4 4 3 3 3 4 4 4 5 5 4 4 4 2 4 4 4 3 3 3 4 4 4 5 5 4 4 4