Пожалуйста, подпишитесь на официальный канал Codeforces в Telegram по ссылке https://t.me/codeforces_official. ×

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

Автор viralm, история, 6 лет назад, По-английски
I am trying to solve a problem where I am given 2 strings A and B. Length of A is n and length of B is m. Now, q queries need to be answered. Each query will consist of 2 integers i and j such that 1 <= i,j <= n. For each such query, I want to find the length of the longest common sub-sequence of A.sub_string(i, j) and B.
Constraints:
1 <= n <= 10^4
1 <= m <= 10^4
1 <= Q <= 10^2

Time Limit: 3 seconds
  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится

»
6 лет назад, # |
Rev. 2   Проголосовать: нравится -29 Проголосовать: не нравится

LCS works in O(nm), with Q queries it will be O(Qnm).