제출 #1322258

#제출 시각아이디문제언어결과실행 시간메모리
1322258khbaPalindromes (APIO14_palindrome)C++20
8 / 100
222 ms149848 KiB
#include "bits/stdc++.h" using namespace std; int32_t main() { ios ::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); string s; cin >> s; int n = s.size(); map<string, int> cnt; for (int i = 0; i < n; ++i) { string p = ""; for (int j = i; j < n; ++j) { p += s[j]; cnt[p]++; } } long long ans = 0; vector<vector<bool>> dp(n, vector<bool>(n)); for (int i = n - 1; ~i; --i) for (int j = i; j < n; ++j) if (i == j) dp[i][j] = true; else dp[i][j] = (j - i + 1 == 2 ? (s[i] == s[j]) : (dp[i + 1][j - 1] and s[i] == s[j])); for (int i = 0; i < n; ++i) { string p = ""; for (int j = i; j < n; ++j) { p += s[j]; if (dp[i][j]) ans = max(ans, 1LL * (int)(p.size()) * cnt[p]); } } cout << ans; } /* addabcadda aa 2 * length */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...