Open buhiroshi0205 opened 2 years ago
The newest increase in mod value at https://github.com/buhiroshi0205/cp-templates/blob/aafd67595de17dccb439685ec67bfb02e86f86ba/RabinKarp.cpp#L17 causes overflow at these locations https://github.com/buhiroshi0205/cp-templates/blob/aafd67595de17dccb439685ec67bfb02e86f86ba/RabinKarp.cpp#L54 https://github.com/buhiroshi0205/cp-templates/blob/aafd67595de17dccb439685ec67bfb02e86f86ba/RabinKarp.cpp#L60 if used as an oracle ONLY WHEN a[start] and b[end-start+1] are big enough (and similarly for reversehash). This problem does not occur when we take the hash of the whole string, only one character, or sometimes nearly the whole string.
Mod value increase needs to be reverted, and a separate method can be created for non-oracle queries that allow bigger mods for smaller bases.
ToDo: find the best prime that doesn't overflow
The newest increase in mod value at https://github.com/buhiroshi0205/cp-templates/blob/aafd67595de17dccb439685ec67bfb02e86f86ba/RabinKarp.cpp#L17 causes overflow at these locations https://github.com/buhiroshi0205/cp-templates/blob/aafd67595de17dccb439685ec67bfb02e86f86ba/RabinKarp.cpp#L54 https://github.com/buhiroshi0205/cp-templates/blob/aafd67595de17dccb439685ec67bfb02e86f86ba/RabinKarp.cpp#L60 if used as an oracle ONLY WHEN a[start] and b[end-start+1] are big enough (and similarly for reversehash). This problem does not occur when we take the hash of the whole string, only one character, or sometimes nearly the whole string.
Mod value increase needs to be reverted, and a separate method can be created for non-oracle queries that allow bigger mods for smaller bases.