diff --git a/S2OJ/166/166.cpp b/S2OJ/166/166.cpp new file mode 100644 index 00000000..9e202e32 --- /dev/null +++ b/S2OJ/166/166.cpp @@ -0,0 +1,46 @@ +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 1.1e7 + 5; + +int p[N << 1], mid, r, ans; +std::string s1, s2; + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> s1; + + // Init + + s2.push_back('^'); + for (const char &c : s1) { + s2.push_back('#'); + s2.push_back(c); + } + s2 += "#$"; + + for (int i = 1; i < s2.size(); i++) { + p[i] = i < r ? std::min(p[mid * 2 - i], r - i) : 1; + + while (s2[i - p[i]] == s2[i + p[i]]) p[i]++; + + if (i + p[i] > r) { + r = i + p[i]; + mid = i; + } + } + + for (int i = 0; i < s2.size(); i++) { + ans = std::max(ans, p[i]); + } + + cout << ans - 1 << endl; + + return 0; +} diff --git a/S2OJ/166/data/problem.conf b/S2OJ/166/data/problem.conf new file mode 100644 index 00000000..c4bb051d --- /dev/null +++ b/S2OJ/166/data/problem.conf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:17c6f45ebc5174a39ae3fe31faeda1c63999fddb61bf0b65190e3ddb5ba33efe +size 191 diff --git a/S2OJ/166/data/std.cpp b/S2OJ/166/data/std.cpp new file mode 100644 index 00000000..70f0c643 --- /dev/null +++ b/S2OJ/166/data/std.cpp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9e8c2545eb2c6971c1671b35a9c98ae0e6589f7635b24e341171d7ffa207ff26 +size 704 diff --git a/S2OJ/166/data/str1.ans b/S2OJ/166/data/str1.ans new file mode 100644 index 00000000..06d04c2c --- /dev/null +++ b/S2OJ/166/data/str1.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aa67a169b0bba217aa0aa88a65346920c84c42447c36ba5f7ea65f422c1fe5d8 +size 2 diff --git a/S2OJ/166/data/str1.in b/S2OJ/166/data/str1.in new file mode 100644 index 00000000..ee133bde --- /dev/null +++ b/S2OJ/166/data/str1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2724649a52d9fb179b748792210f7eaa52c693cabd30e64cab47d3768e790832 +size 51 diff --git a/S2OJ/166/data/str10.ans b/S2OJ/166/data/str10.ans new file mode 100644 index 00000000..74bab9c1 --- /dev/null +++ b/S2OJ/166/data/str10.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dfa04216492241c1c77ae12737e908380acae749f8dfddfba303e8d224e5306d +size 9 diff --git a/S2OJ/166/data/str10.in b/S2OJ/166/data/str10.in new file mode 100644 index 00000000..d2c816eb --- /dev/null +++ b/S2OJ/166/data/str10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ae54c2b04bef1dcb54a8f5f9284a44e6979cd31a3f89a319be354315c3854f62 +size 11000001 diff --git a/S2OJ/166/data/str2.ans b/S2OJ/166/data/str2.ans new file mode 100644 index 00000000..2ccf849a --- /dev/null +++ b/S2OJ/166/data/str2.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:238903180cc104ec2c5d8b3f20c5bc61b389ec0a967df8cc208cdc7cd454174f +size 3 diff --git a/S2OJ/166/data/str2.in b/S2OJ/166/data/str2.in new file mode 100644 index 00000000..55721910 --- /dev/null +++ b/S2OJ/166/data/str2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4dc3615ee59c399d23f167bc42106cf08a060e1fde6db3cf5d4bb6727a766812 +size 201 diff --git a/S2OJ/166/data/str3.ans b/S2OJ/166/data/str3.ans new file mode 100644 index 00000000..6146a6fe --- /dev/null +++ b/S2OJ/166/data/str3.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ea243e5457028e97f9bc93b37a72f8e80ea61ae081911bb037765590ee6aa435 +size 3 diff --git a/S2OJ/166/data/str3.in b/S2OJ/166/data/str3.in new file mode 100644 index 00000000..4d6d7abc --- /dev/null +++ b/S2OJ/166/data/str3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:05ce73c8476446fb26ae206ade31e8e9beab2796fdf0d8e47c0b77500fd81eec +size 1001 diff --git a/S2OJ/166/data/str4.ans b/S2OJ/166/data/str4.ans new file mode 100644 index 00000000..dee03707 --- /dev/null +++ b/S2OJ/166/data/str4.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:64459cd36006fa4bb2f5314f2a1ad69c8cbbb95f319c5459b32a9cdc870b54aa +size 3 diff --git a/S2OJ/166/data/str4.in b/S2OJ/166/data/str4.in new file mode 100644 index 00000000..8dbdfe7d --- /dev/null +++ b/S2OJ/166/data/str4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:03bca9713b628fb68517efef69e5bd214c61d38bfeee380430bb965c227322b7 +size 2001 diff --git a/S2OJ/166/data/str5.ans b/S2OJ/166/data/str5.ans new file mode 100644 index 00000000..769cab55 --- /dev/null +++ b/S2OJ/166/data/str5.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2bdf9d338b52a6abe2f0d3da71b0f25531027e553654c5c5efd1e543ee94ee01 +size 6 diff --git a/S2OJ/166/data/str5.in b/S2OJ/166/data/str5.in new file mode 100644 index 00000000..f913bc64 --- /dev/null +++ b/S2OJ/166/data/str5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b40fce1c967a7d4a7f57a4bab87cc030f73d85e21cfd7e1fbbd797355420a461 +size 100001 diff --git a/S2OJ/166/data/str6.ans b/S2OJ/166/data/str6.ans new file mode 100644 index 00000000..1f59985b --- /dev/null +++ b/S2OJ/166/data/str6.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4904fd5e0c9950a84ada002d68cfad9f02aaefaf58717f7c821dab2ab9e5d255 +size 6 diff --git a/S2OJ/166/data/str6.in b/S2OJ/166/data/str6.in new file mode 100644 index 00000000..e50195ed --- /dev/null +++ b/S2OJ/166/data/str6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f2e891e41eec4744057f0058913413478a10ae1c85f82b1d15b43b11dcc7b61d +size 100001 diff --git a/S2OJ/166/data/str7.ans b/S2OJ/166/data/str7.ans new file mode 100644 index 00000000..c348b05c --- /dev/null +++ b/S2OJ/166/data/str7.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ab19366a20bc851233e92fafb38363d09c3007ba0ced8acf50e835a49ae0339b +size 7 diff --git a/S2OJ/166/data/str7.in b/S2OJ/166/data/str7.in new file mode 100644 index 00000000..cab99c8b --- /dev/null +++ b/S2OJ/166/data/str7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7eff67869e147a54e809dd9872366d30398324b94612474f8d6554ff1d811ac9 +size 11000001 diff --git a/S2OJ/166/data/str8.ans b/S2OJ/166/data/str8.ans new file mode 100644 index 00000000..47fd8e65 --- /dev/null +++ b/S2OJ/166/data/str8.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cace2280da4239026eb9c3c7207d3f1b552ef5c4f1b437f1da161ec6849a460c +size 7 diff --git a/S2OJ/166/data/str8.in b/S2OJ/166/data/str8.in new file mode 100644 index 00000000..a39d621e --- /dev/null +++ b/S2OJ/166/data/str8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bd0ca78d6985c669c0d42b3afe3c4f2b64c1f0ad9796af85614e1c5529a389a6 +size 11000001 diff --git a/S2OJ/166/data/str9.ans b/S2OJ/166/data/str9.ans new file mode 100644 index 00000000..243750ab --- /dev/null +++ b/S2OJ/166/data/str9.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b637dad5b38a0b423bc25743c6f5f0379510ed455b041c0293a803953a2bdc67 +size 7 diff --git a/S2OJ/166/data/str9.in b/S2OJ/166/data/str9.in new file mode 100644 index 00000000..b8ba18ca --- /dev/null +++ b/S2OJ/166/data/str9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b49dedaa3308dace8fae368a13ffbdb850126e2154188eac4ab7ba869ca7fb6a +size 11000001 diff --git a/S2OJ/166/data/val.cpp b/S2OJ/166/data/val.cpp new file mode 100644 index 00000000..759c6075 --- /dev/null +++ b/S2OJ/166/data/val.cpp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:320c3d133f86ecd8129986b89a4c5a1bc81b557a420c10d44bdd4e07a3c096d6 +size 361