diff options
Diffstat (limited to 'string/lyndon.cpp')
| -rw-r--r-- | string/lyndon.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/string/lyndon.cpp b/string/lyndon.cpp new file mode 100644 index 0000000..6a131a5 --- /dev/null +++ b/string/lyndon.cpp @@ -0,0 +1,11 @@ +bool next(string& s, int n, char mi = '0', char ma = '1') { + for (ll i = sz(s), j = sz(s); i < n; i++) + s.push_back(s[i % j]); + while(!s.empty() && s.back() == ma) s.pop_back(); + if (s.empty()) { + s = mi; + return false; + } else { + s.back()++; + return true; +}} |
