답안 #990759

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
990759 2024-05-31T07:31:18 Z vjudge1 Palinilap (COI16_palinilap) C++17
17 / 100
1000 ms 600 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 404 KB Output is correct
2 Correct 76 ms 348 KB Output is correct
3 Correct 76 ms 344 KB Output is correct
4 Correct 76 ms 404 KB Output is correct
5 Correct 76 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1066 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1043 ms 600 KB Time limit exceeded
2 Halted 0 ms 0 KB -