From 74f7d3edd903099be9343607f4b5f1a3f82c5a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=E1=BB=B3nh=20Tr=E1=BA=A7n=20Khanh?= Date: Thu, 25 Aug 2022 21:20:26 +0700 Subject: [PATCH 1/2] Add `const` --- content/strings/Hashing.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/strings/Hashing.h b/content/strings/Hashing.h index c91746d06..9ddc96960 100644 --- a/content/strings/Hashing.h +++ b/content/strings/Hashing.h @@ -28,7 +28,7 @@ static const H C = (ll)1e11+3; // (order ~ 3e9; random also ok) struct HashInterval { vector ha, pw; - HashInterval(string& str) : ha(sz(str)+1), pw(ha) { + HashInterval(const string& str) : ha(sz(str)+1), pw(ha) { pw[0] = 1; rep(i,0,sz(str)) ha[i+1] = ha[i] * C + str[i], @@ -39,7 +39,7 @@ struct HashInterval { } }; -vector getHashes(string& str, int length) { +vector getHashes(const string& str, int length) { if (sz(str) < length) return {}; H h = 0, pw = 1; rep(i,0,length) @@ -51,4 +51,4 @@ vector getHashes(string& str, int length) { return ret; } -H hashString(string& s){H h{}; for(char c:s) h=h*C+c;return h;} +H hashString(const string& s){H h{}; for(char c:s) h=h*C+c;return h;} From 8791abe4168848748a7c0bda4b838caf3292c1db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=E1=BB=B3nh=20Tr=E1=BA=A7n=20Khanh?= Date: Thu, 25 Aug 2022 21:21:55 +0700 Subject: [PATCH 2/2] Add `const` --- content/strings/Hashing-codeforces.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/strings/Hashing-codeforces.h b/content/strings/Hashing-codeforces.h index b8b4f1421..57d823677 100644 --- a/content/strings/Hashing-codeforces.h +++ b/content/strings/Hashing-codeforces.h @@ -27,7 +27,7 @@ typedef A<1000000007, A<1000000009, unsigned>> H; struct HashInterval { vector ha, pw; - HashInterval(string& str) : ha(sz(str)+1), pw(ha) { + HashInterval(const string& str) : ha(sz(str)+1), pw(ha) { pw[0] = 1; rep(i,0,sz(str)) ha[i+1] = ha[i] * C + str[i], @@ -38,7 +38,7 @@ struct HashInterval { } }; -vector getHashes(string& str, int length) { +vector getHashes(const string& str, int length) { if (sz(str) < length) return {}; H h = 0, pw = 1; rep(i,0,length) @@ -50,7 +50,7 @@ vector getHashes(string& str, int length) { return ret; } -H hashString(string& s){H h{}; for(char c:s) h=h*C+c;return h;} +H hashString(const string& s){H h{}; for(char c:s) h=h*C+c;return h;} #include int main() {