Submission #990759

#TimeUsernameProblemLanguageResultExecution timeMemory
990759vjudge1Palinilap (COI16_palinilap)C++17
17 / 100
1066 ms600 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll base = 727, mod = 1e9 + 9; int main(){ string s; cin >> s; int n = s.size(); int ans = 0; for (int pos = 0; pos < n; pos ++){ char p = s[pos]; for (char c = 'a'; c <= 'z'; c ++){ s[pos] = c; int cnt = 0; for (int l = 0; l < n; l ++){ ll hsh1 = 0; ll hsh2 = 0; ll pw = 1; for (int r = l; r < n; r ++){ hsh1 = (hsh1 * base + s[r]) % mod; hsh2 = (hsh2 + pw * s[r]) % mod; pw = (pw * base) % mod; if (hsh1 == hsh2) cnt++; } } ans = max(ans, cnt); } s[pos] = p; } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...