結果

問題 No.273 回文分解
ユーザー Mister
提出日時 2020-04-13 21:32:08
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 509 bytes
コンパイル時間 622 ms
コンパイル使用メモリ 68,736 KB
最終ジャッジ日時 2025-01-09 18:12:41
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>

void solve() {
    std::string s;
    std::cin >> s;
    int n = s.length();

    int ans = 0;
    for (int l = 1; l < n; ++l) {
        for (int i = 0; i + l <= n; ++i) {
            auto t = s.substr(i, l);
            if (t == std::string(t.rbegin(), t.rend())) {
                ans = l;
            }
        }
    }

    std::cout << ans << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}
0