Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

cd_mas7er's blog

By cd_mas7er, history, 5 years ago, In English

Hello,

problem :- link

I am finding a difficulty in understanding why does one of my solution pass and the other is giving tle although i think the time complexity of both the codes are same.

tle code — link

ac code — link

tle code — i have written a recursive function and i am using 2d dp where dp[i][j] means minimum cost of opening those locks where the bit is set in the binary representation of j using only 0 to i keys. Base case — if i==m , that is all the keys are taken into consideration if the binary representation of j does not have all the bits set to 1 , then all the locks are not opened , return infinity and if all the locks are opened then return 0.

ac code — i have just written an iterative function and taken 1d dp where dp[i] = minimum cost of opening those locks where bit is set in the binary representation of i.

the time complexity of TLE code at worst can go O(m*(2^n)) because this the dimension of the dp i am filling and ac code has time complexity as O(m*(2*n)). Since both the solution have same time complexity i don't know why one is gettiing tle and other is not.

Could anyone please tell me what i am doing wrong. Thanks in advance.

Full text and comments »

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

By cd_mas7er, history, 5 years ago, In English

Hello Everyone :)

I and my friend are going to do practice for improving our skills and rank in competitive programming this summer and so, we would be very happy if anyone who is also devoting their time in improving their skills in competitive programming would join us.

Both of us are at specialist level and would be very glad if anyone on expert level or specialist level joins us . Anyone who is interested message me.

Update Since i can only reply to 3 users in a day at codeforces please message me at [email protected] along with a link to your codeforces id

Thank you :)

Full text and comments »

  • Vote: I like it
  • -8
  • Vote: I do not like it