結果

問題 No.599 回文かい
ユーザー TakatenTakaten
提出日時 2017-11-24 23:33:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 854 bytes
コンパイル時間 1,610 ms
コンパイル使用メモリ 171,904 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-18 05:27:23
合計ジャッジ時間 2,677 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 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 AC 3 ms
4,380 KB
testcase_15 WA -
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 WA -
testcase_20 AC 1 ms
4,380 KB
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--) {
        ans++;
        if (t[i].size() == 1 && i != 0 && t[i - 1] == t[i]) {
            ans = ans * 2 - 1;
            ans %= MOD;
        }
    }

    cout << ans << endl;

    return 0;
}
0