結果
| 問題 | No.588 空白と回文 | 
| コンテスト | |
| ユーザー |  zaichu | 
| 提出日時 | 2017-11-15 22:25:45 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 159 ms / 2,000 ms | 
| コード長 | 797 bytes | 
| コンパイル時間 | 1,808 ms | 
| コンパイル使用メモリ | 166,904 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-11-25 04:01:03 | 
| 合計ジャッジ時間 | 2,987 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 25 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T x, T y)
{
    if (y == 0)
        return x;
    return gcd(y, x % y);
}
template <typename T>
T lcm(T x, T y)
{
    if (x == 0 || y == 0)
        return 0;
    return x / gcd(x, y) * y;
}
int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int ans = 1;
    for (int i = 0; i < n; i++)
    {
        for (int j = n - 1; j > i; j--)
        {
            if (s[i] != s[j])
                continue;
            int cnt = 0;
            int l = i, r = j;
            while (l <= r)
            {
                if (s[l] == s[r])
                    cnt += (l == r ? 1 : 2);
                l++;
                r--;
            }
            ans = max(ans, cnt);
        }
    }
    cout << ans << endl;
}
            
            
            
        