rachitnaruzu's blog

By rachitnaruzu, 12 years ago, In English

link to problem: Watto and Mechanism

I used C++ maps and mapped all n strings in map, initially, like this:

//map<string,bool> m;
m[str] = true;

then for each query string s of length L, produced 3*L modified_strings (meaning: at every position in original string, putting 'a','b','c' to produce 3*L modified _strings with only one character difference from s) and check whether any of them are in map, like this:

//let t be one of the modified string
if(m[modified_string]) flag = true;

if any one of them is present in map then print "YES" otherwise "NO". But this solution is giving Wrong answer on pretest 6. Here 10118407 is my code. And secondly, i was not able to get the idea of using polynomial hashing, can anyone please explain ?

Full text and comments »

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