Скоро Codeforces Round 1133 (Div. 1, Div. 2)! Регистрация здесь. ×

Блог пользователя Mukit09

Автор Mukit09, 13 лет назад, По-английски

Two string will be given. I've to find out lexicographically smallest LCS string. I have coded one, but it is giving me WA... I tried with some cases, but failed to find out the problem. Would anyone help please ???

I just need the case for which case my code is failed... Please help ... :(

My code is here

Problem Link is here

Теги dp
  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
13 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

I have no idea why you use so many pointers and char arrays and moreover why you pass it to one of your functions (I'm sure if you pass the test you have WA currently u'll get TLE due to many strcpys).

I would just reverse strings and make DP[][] and B[][] matrices (see CLRS for details) and if s1[i]!=s2[j] and DP[i-1][j] is equal to DP[i][j-1] choose lexicographically smaller.

Lastly, using B[][] determine the answer and reverse it.