Codeforces celebrates 10 years! We are pleased to announce the crowdfunding-campaign. Congratulate us by the link https://codeforces.com/10years. ×

saurabhs1206's blog

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

I tried to understand the solutions of few people but couldn't exactly get it. Besides, couldn't find the editorial for the problem. It'd be really great if someone could help me out. Problem Link

Read more »

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

By saurabhs1206, history, 7 months ago, In English,

I have been trying to solve the problem CPATTERN from SPOJ. Link: https://www.spoj.com/problems/CPATTERN/.

I store the input sequence in text[] and subgroup sequence in pattern[]. Using text[], I created another array diffText[] that stores:

diffText[i] = 1 if text[i - 1] > text[i],
diffText[i] = 0 if text[i - 1] == text[i],
diffText[i] = -1 if text[i - 1] < text[i]

In the same way, I construct the array diffPattern[] for pattern[]. Then I use KMP to search for the diffPattern[] in diffText[]. It shows wrong answer. Is this incorrect approach? Please help.

Read more »

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