結果

問題 No.464 PPAP
ユーザー nebukuro09nebukuro09
提出日時 2016-12-16 00:15:30
言語 D
(dmd 2.106.1)
結果
TLE  
実行時間 -
コード長 881 bytes
コンパイル時間 802 ms
コンパイル使用メモリ 97,084 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-02 23:35:04
合計ジャッジ時間 4,780 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
7,060 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 6 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 TLE -
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 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio;
import std.array;
import std.string;
import std.conv;
import std.algorithm;
import std.typecons;
import std.range;
import std.random;
import std.math;
import std.container;
import std.numeric;
import std.bigint;
import core.bitop;


alias Tuple!(int, "l", int, "r") kaibun;
string S;
int N;

bool is_kaibun(int l, int r) {
  foreach (i; 0..(r-l+1)/2)
    if (S[l+i] != S[r-i])
      return false;
  return true;
}

void main() {
  S = readln.chomp;
  N = S.length.to!int;

  kaibun[] P1;
  foreach (i; 0..N)
    if (is_kaibun(0, i))
      P1 ~= kaibun(0, i);

  kaibun[] P3;
  foreach (i; 0..N)
    if (is_kaibun(i, N-1))
      P3 ~= kaibun(i, N-1);

  int ans = 0;
  foreach (p1; P1)
    foreach (p3; P3) {
      if (p3.l - p1.r <= 2)
        continue;
      foreach (i; p1.r+1..p3.l-1)
        if (is_kaibun(p1.r+1, i))
          ans++;
    }

  ans.writeln;
}
0