結果

問題 No.765 ukuku 2
ユーザー treeonetreeone
提出日時 2018-10-29 22:55:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 838 bytes
コンパイル時間 2,151 ms
コンパイル使用メモリ 202,168 KB
実行使用メモリ 8,652 KB
最終ジャッジ日時 2023-08-26 19:56:51
合計ジャッジ時間 3,739 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 WA -
testcase_12 AC 1 ms
4,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 2 ms
4,380 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 12 ms
8,644 KB
testcase_34 AC 12 ms
8,564 KB
testcase_35 AC 12 ms
8,648 KB
testcase_36 WA -
testcase_37 AC 12 ms
8,652 KB
testcase_38 AC 12 ms
8,604 KB
testcase_39 WA -
testcase_40 AC 10 ms
7,512 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

vector<int> manacher(string s){
    int i = 0, j = 0;
    vector<int> res(s.size());
    while (i < s.size()) {
        while (i - j >= 0 && i + j < s.size() && s[i - j] == s[i + j]) ++j;
        res[i] = j;
        int k = 1;
        while (i - k >= 0 && i + k < s.size() && k + res[i - k] < j) res[i + k] = res[i - k], ++k;
        i += k; j -= k;
    }
    return res;
}

int main(){
    int n, ans = 0;
    string s;
    cin >> s;
    n = s.size();
    string t = "$";
    for(int i = 0; i < s.size(); i++){
        t += s[i]; t += "$";
    }
    s = t;
    vector<int> len = manacher(s), left(s.size()), right(s.size());
    for(int i = 0; i < len.size(); i++){
        len[i]--;
        if(len[i] != n) ans = max(ans, len[i]);
        else ans = n - 1;
    }
    cout << ans << endl;
}
0