Codeforces Round 1133 (Div. 1, Div. 2) is coming soon! Register here. ×

ar_rony1's blog

By ar_rony1, history, 6 years ago, In English

How can i solve following problem using string hashing? SUB_PROB

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

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

Use Rabin-Karp Algorithm. It uses string hashing.

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

    Ok thanks!

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

    Isn't the time limit too strict for Rabin-Karp?

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

      Rabin-karp complexity is O(n*m) and this problem time limit is 0.100s. So what will be the better approach?

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

        I couldn't come up with anything using string hashing, but the problem might be solved using suffix array with complexity O(MlogM + N*logM). (still not sure if it's gonna pass since time limit is too tight) You can check it out here.