kishore_p's blog

By kishore_p, history, 6 years ago, In English

Solving This problem using Heavy-light Decomposition after reading from this blog. Tried all cases from spoj tool kit it works fine but still getting wrong answer. I have written a neat code. Please help

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By kishore_p, history, 6 years ago, In English

Iam learning Suffix array from this blog and trying to solve DISUBSTR — Distinct Substrings from spoj . Getting wrong answer for this code submission . Not able to figure out the mistake. Please help. Thanks

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By kishore_p, history, 6 years ago, In English

I used Mo's algo to solve this problem .

First compare function: It gives me wrong answer Submission1

bool comp(query &a,query &b)
{
 int x=a.L/bsize;
 int y=b.L/bsize;
 
 if(x!=y)
 return x<y;
 if(x&1)
 return (a.R > b.R);
 else
 return (a.R < b.R);
}

Second function : Gives me AC Submission2

bool comp(query &a,query &b)
{
 int x=a.L/bsize;
 int y=b.L/bsize;
 
 if(x!=y)
 return x<y;
 else
 return a.R < b.R;
}

First one is an optimisation,but not able to find why it gives wrong answer

Full text and comments »

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