結果

問題 No.599 回文かい
ユーザー TakatenTakaten
提出日時 2017-11-24 23:47:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,109 bytes
コンパイル時間 1,791 ms
コンパイル使用メモリ 170,924 KB
実行使用メモリ 8,352 KB
最終ジャッジ日時 2023-08-18 05:31:33
合計ジャッジ時間 7,342 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
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--) {
        if (t[i].size() == 1 && i > 0) {
            int cnt = 1;
            int j = i - 1;
            string tmp = t[i];
            while (t[j].size() == 1 && j > 0) {
                tmp += t[j];
                if (tmp.substr(0, tmp.size() / 2) == tmp.substr(tmp.size() / 2 + 1)) cnt++;
            }
            ans = ans * (1 + cnt);
            ans %= MOD;
        }
        ans++;
    }

    cout << ans % MOD << endl;

    return 0;
}
0