結果

問題 No.599 回文かい
ユーザー illanastyillanasty
提出日時 2021-12-02 15:21:35
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,632 bytes
コンパイル時間 7,383 ms
コンパイル使用メモリ 106,580 KB
実行使用メモリ 4,564 KB
最終ジャッジ日時 2023-09-18 10:18:07
合計ジャッジ時間 11,341 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 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 AC 2 ms
4,376 KB
testcase_07 WA -
testcase_08 WA -
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 <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>


using namespace std;


using ll = long long;
using ld = long double;


#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)


template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
template<class T> using pq  = priority_queue<T>;


template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return true; } return false; }


constexpr int MOD = 1000000007;


int pow2[10005];


int main() {
  string s;
  cin >> s;

  int n = s.size();

  pow2[0] = 1;
  rep(i, 10004) pow2[i+1] = (pow2[i] * 2) % MOD;

  vector<string> ts;
  int sum = 0;
  string a, b, c;

  rep(i, n/2) {
    a += s[i];
    b = s[n-i-1] + b;

    if (a == b) {
      ts.push_back(a);
      sum += a.size();
      a = b = "";
    }
  }

  c = s.substr(sum, n - 2 * sum);

  int ans = 0, streak = 0;
  string last;

  for (string t : ts) {
    if (t == last) {
      ++streak;
    } else {
      ans += pow2[streak];
      ans %= MOD;
      streak = 0;
    }
  }

  bool isPalin = false;
  string d = c;
  reverse(all(c));

  if (d == c) isPalin = true;

  if (isPalin) ans += ts.size();
  else ++ans;
  
  ans %= MOD;
  cout << ans << endl;

  return 0;
}
0