結果

問題 No.599 回文かい
ユーザー TakatenTakaten
提出日時 2017-11-25 00:19:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,660 bytes
コンパイル時間 1,843 ms
コンパイル使用メモリ 172,680 KB
実行使用メモリ 7,988 KB
最終ジャッジ日時 2023-08-18 05:41:00
合計ジャッジ時間 16,475 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
7,864 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 TLE -
testcase_15 WA -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
evil_0.txt -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000
#define MOD 1000000007

using namespace std;

typedef pair<int, int> P;
typedef long long int LL;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    vector<string> t;
    string f = "", b = "";
    int l = 0, r = n - 1;
    while (l < r) {
        f += s[l]; b = s[r] + b;
        l++; r--;
        if (f == b) {
            t.pb(f);
            f = "";
            b = "";
        }
    }

    // for (int i = 0; i < t.size(); i++) {
    //     cout << t[i] << endl;
    // }

    LL ans = 1;
    LL cnt = 0;
    for (int i = t.size() - 1; i >= 0; i--) {
        int cnt = 0;
        int j = i - 1;
        string tmp = t[i];
        // cout << tmp << endl;
        while (j >= 0) {
            tmp += t[j];
            // cout << "tmp = " << tmp << endl;
            if (tmp.size() % 2 == 0) {
                string rev = tmp.substr(tmp.size() / 2);
                reverse(rev.begin(), rev.end());
                if (tmp.substr(0, tmp.size() / 2) == rev) {
                    cnt++;
                }
            } else {
                // cout << tmp.substr(0, tmp.size() / 2) << " " << tmp.substr(tmp.size() / 2 + 1) << endl;
                string rev = tmp.substr(tmp.size() / 2 + 1);
                reverse(rev.begin(), rev.end());
                if (tmp.substr(0, tmp.size() / 2) == rev) {
                    cnt++;
                }
            }
            j--;
        }
        // cout << ans << " " << cnt << endl;
        ans += ans * cnt;
        ans++;
        ans %= MOD;
    }

    cout << ans % MOD << endl;

    return 0;
}
0