Tobby_And_Friends's blog

By Tobby_And_Friends, history, 3 weeks ago, In English,

Problem: http://www.spoj.com/problems/ADACLEAN/ Solution: http://ideone.com/TracEP Verdict: Wrong Answer

I just learned about hashing and tried to solve this problem using the technique. My idea is I will pre-process _hash array with the hash values and afterwards I will just extract hashes of all the k-length strings and keep that in a map. Afterwards, I just output the size of the map. Any help to identify my mistake is really appreciated.

Read more »

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

By Tobby_And_Friends, history, 6 weeks ago, In English,

Problem Link: https://uva.onlinejudge.org/external/125/12546.pdf

I understand that LCM is a multiplicative function. So, for the case where n = 6, it should be like f(6) = f(2) * f(3), f(2) = (1 + 2) + (2 + 2) = 7, f(3) = (1 + 3) + (3 + 3) = 10, therefore f(6) = f(2) * f(3) = 7 * 10 = 70. But this is the wrong answer. Someone please help me out to figure out the right solution. Any help is really appreciated.

Read more »

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

By Tobby_And_Friends, history, 6 weeks ago, In English,

I understand the O(nlog^2n) implementation but I want to learn the nlogn implementation. So, if anyone can suggest me any blog or tutorial related to this it would be very helpful.

Read more »

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

By Tobby_And_Friends, history, 6 weeks ago, In English,

What are some recommended problems from Kattis online judge?

Read more »

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

By Tobby_And_Friends, history, 7 weeks ago, In English,

Problem link: http://www.spoj.com/problems/PATULJCI/

Solution link: http://ideone.com/NqSI3j

Verdict: TLE

I tried to use Mo's algorithm and segment tree to solve the problem. How do I further optimize my solution? Any help is really appreciated.

Read more »

 
 
 
 

By Tobby_And_Friends, history, 7 weeks ago, In English,

Link: https://uva.onlinejudge.org/external/117/11774.pdf

I understand that the for n == m answer is 2. But I can't figure out the solution when n != m. I mean I basically do not understand the theory behind the solution (apart from trying out for small test cases). Any help is really appreciated.

Read more »

 
 
 
 

By Tobby_And_Friends, history, 7 weeks ago, In English,

Link: https://uva.onlinejudge.org/external/108/10883.pdf

I could figure out that let's say for 5 numbers the answer is (Arr[1] + 4 * Arr[2] + 6 * Arr[3] + 4 * Arr[4] + Arr[5])/2^16. So the problem basically reduces to finding the values in the nth row of pascal's triangle and power of 2. But I am not very sure as to how to implement the solution. Any help is really appreciated.

Read more »

 
 
 
 

By Tobby_And_Friends, history, 2 months ago, In English,

How to determine whether a number is a product of consecutive primes? The number can be at max 10^14. Any hints is really appreciated.

Read more »

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

By Tobby_And_Friends, history, 3 months ago, In English,

Problem Link: https://uva.onlinejudge.org/external/12/1223.pdf

My implementation: http://ideone.com/bLGTpc

Verdict: WA

Anyone please help me to figure out my mistake. I learned Suffix Array today and this is my first implementation. Any help is really appreciated.

Read more »

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

By Tobby_And_Friends, history, 3 months ago, In English,

Anyone please suggest me some beginner-level/basic problems on DP on Trees. Thanks in advance.

Read more »

 
 
 
 

By Tobby_And_Friends, history, 4 months ago, In English,

Any hint is really appreciated.

Problem link: https://uva.onlinejudge.org/external/17/1734.pdf

Read more »

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

By Tobby_And_Friends, history, 4 months ago, In English,

Problem name: Count LCM

Link: https://uva.onlinejudge.org/external/128/12888.pdf

Let's say n < m. Then the answer is for each integers i, from 1 to n, how many integers up to m are co-prime with i. I tried solving the problem but it got me a TLE. How do I optimize my solution? Any help is really appreciated.

Solution Link: http://ideone.com/mMoWMS

Read more »

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

By Tobby_And_Friends, history, 4 months ago, In English,

Problem link: https://www.hackerrank.com/challenges/digit-products

My solution: http://ideone.com/wXDPi3

I got a verdict of TLE. How can I optimize my code further? Any help is really appreciated.

Read more »

 
 
 
 

By Tobby_And_Friends, history, 4 months ago, In English,

Problem Link: https://uva.onlinejudge.org/external/124/12429.pdf

Any hints to solve the problem is really appreciated.

Read more »

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

By Tobby_And_Friends, history, 4 months ago, In English,

I recently studied Mo's algorithm on trees. Please help me out with some problems to practice. Any help is really appreciated.

Read more »

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

By Tobby_And_Friends, history, 4 months ago, In English,

I do understand the query, i.e, query of type 1 A means adding 1 to the value at A, query of type 2 X means how many queue has pilgrims of length >= X and query of type 3 Y means to subtract 1 from each of the queues having >= Y pilgrims. I'm just not sure how to process my original arrays so that I can easily update using BIT. Any hint will be really appreciated.

Problem Link: http://www.spoj.com/problems/TEMPLEQ/

Read more »

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

By Tobby_And_Friends, history, 4 months ago, In English,

Problem Link: http://www.spoj.com/problems/SEGSQRSS/

While I do understand that the merge operation can be deduced from the equation (a + b)^2 = a^2 + b^2 — 2ab I could not specifically figure out how would I formulate the merge operation. Any help is really appreciated.

Read more »

 
 
 
 

By Tobby_And_Friends, history, 4 months ago, In English,

Problem Name: KQUERY — K-query

Problem Link: http://www.spoj.com/problems/KQUERY/

My solution: http://ideone.com/4COpOu

verdict: TLE

How do I further optimize my solution?

Any help is really appreciated.

Read more »

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

By Tobby_And_Friends, history, 4 months ago, In English,

Problem Link: http://www.spoj.com/problems/NUMTSN/

My solution: http://ideone.com/7fKLqx

Any help is really appreciated.

Read more »

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

By Tobby_And_Friends, history, 4 months ago, In English,

Problem Link: http://codeforces.com/problemset/problem/731/F

Solution Link: http://ideone.com/3UYOmF

I got WA in test case 7. What is wrong with my solution?

Read more »

 
 
 
 

By Tobby_And_Friends, history, 4 months ago, In English,

I just read this tutorial today https://threads-iiith.quora.com/Dynamic-Programming-on-Trees-Tutorial Please help me with some problems to solve.

Read more »

 
 
 
 

By Tobby_And_Friends, history, 5 months ago, In English,

UVA 13085

Problem Name: Forming Teams

Problem link: https://uva.onlinejudge.org/contests/364-bb2339ba/13085.pdf

I understand that for a number n I need to find out all of its divisors and then I need to find out the possible combinations for each divisor. I could not figure out how to come up with the combinations. Any help is really appreciated.

Read more »

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

By Tobby_And_Friends, history, 5 months ago, In English,

Problem Name: Maximum number, GCD condition (ANUGCD)

Problem Link: https://www.codechef.com/MARCH14/problems/ANUGCD

My implementation: http://ideone.com/TXHpuW

Verdict: Wrong Answer

Anyone please help me out to find why did I get a WA. Thanks in advance.

Read more »

 
 
 
 

By Tobby_And_Friends, history, 5 months ago, In English,

UVA 13083

Name: Yet another GCDSUM

Link: https://uva.onlinejudge.org/external/130/13083.pdf

I did get the idea that I'll initially compute all the divisors of N using prime factorization & backtracking but I'm stuck in how to compute the gcd of the divisor pairs with a better complexity than O(n^2). Any help is really appreciated.

Read more »

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

By Tobby_And_Friends, history, 6 months ago, In English,

How do I go on into solving probability/expected value problems? I'm really struggling with such kind of problems. I feel I understand the solution partially and I am not able to formulate the whole solution. Any help, suggestion, step-wise guidelines for practice is really appreciated.

Read more »

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