結果

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

テストケース

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

ソースコード

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 (i > 0) {
            int cnt = 0;
            int j = i - 1;
            string tmp = t[i];
            while (j >= 0) {
                tmp += t[j];
                // cout << "tmp = " << tmp << endl;
                if (tmp.size() % 2 == 0) {
                    // cout << tmp.substr(0, tmp.size() / 2) << " " << tmp.substr(tmp.size() / 2) << endl;
                    if (tmp.substr(0, tmp.size() / 2) == tmp.substr(tmp.size() / 2)) {
                        cnt++;
                    }
                } else {
                    // cout << tmp.substr(0, tmp.size() / 2) << " " << tmp.substr(tmp.size() / 2 + 1) << endl;
                    if (tmp.substr(0, tmp.size() / 2) == tmp.substr(tmp.size() / 2 + 1)) {
                        cnt++;
                    }
                }
                j--;
            }
            ans += ans * cnt;
            ans %= MOD;
        }
        ans++;
    }

    cout << ans % MOD << endl;

    return 0;
}
0