Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.007 s | 2 KBi |
#2 |
Correcto
|
0.02 s | 1 KBi |
#3 |
Correcto
|
0.009 s | 1 KBi |
#4 |
Correcto
|
0.011 s | 1 KBi |
#5 |
Correcto
|
0.008 s | 1 KBi |
#6 |
Correcto
|
0.008 s | 3 KBi |
#7 |
Correcto
|
0.013 s | 3 KBi |
#8 |
Correcto
|
0.016 s | 3 KBi |
#9 |
Correcto
|
0.015 s | 3 KBi |
#10 |
Correcto
|
0.015 s | 3 KBi |
#11 |
Correcto
|
0.016 s | 3 KBi |
#12 |
Correcto
|
0.016 s | 3 KBi |
#13 |
Correcto
|
0.015 s | 3 KBi |
#14 |
Correcto
|
0.016 s | 3 KBi |
#15 |
Correcto
|
0.017 s | 3 KBi |
#16 |
Correcto
|
0.015 s | 3 KBi |
#17 |
Correcto
|
0.025 s | 3 KBi |
#18 |
Correcto
|
0.015 s | 3 KBi |
#19 |
Correcto
|
0.017 s | 3 KBi |
#20 |
Correcto
|
0.015 s | 3 KBi |
#21 |
Correcto
|
0.021 s | 3 KBi |
#22 |
Correcto
|
0.016 s | 3 KBi |
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define ll long long #define pii pair<int, int> const int maxi = 100000; const ll M = 999727999; const ll P = 1610612741; ll hasha[maxi]; ll pott[maxi]; int main(){ ios::sync_with_stdio(0); cin.tie(0); //USING HASHING string s; cin>>s; ll pot =1; for(int i=0;i<s.size(); i++){ hasha[i+1] =(hasha[i]+(pot*(s[i]-'a'+1)))%M; pott[i+1] = pot; pot = (pot*P)%M; } int j=s.size(); int ans = 0; for(int i=1;i<s.size();i++){ if((hasha[i]*pott[j-i+1])%M==((hasha[j]-hasha[j-i]+M)%M)){ ans=i; } } cout<<ans<<endl; return 0; }