Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

Yellow.Flash's blog

By Yellow.Flash, history, 7 years ago, In English

problem B google kickstart

Someone please explain the approach for this problem.

Thanks

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

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by Yellow.Flash (previous revision, new revision, compare).

»
7 years ago, # |
Rev. 3   Vote: I like it +4 Vote: I do not like it

calc dp[i][j] -> is there a string, that suitable prefix i of the first template and the prefix j of the second pattern?

and then easy transitions:


dp[0][0] = true; if (a[i] != '*' && b[j] != '*' && a[i] == b[j]) { dp[i + 1][j + 1] |= dp[i][j]; } if (a[i] == '*') { dp[i + 1][j] |= dp[i][j]; dp[i + 1][j + 1] |= dp[i][j]; } if (b[j] == '*') { dp[i][j + 1] |= dp[i][j]; dp[i + 1][j + 1] |= dp[i][j]; }

answer in dp[n][m]

  • »
    »
    7 years ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    How you are using this information : A star can match between zero and four letters ?

    • »
      »
      »
      7 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      oh, sorry, i misread this. you can copy one star 4 times :)