結果

問題 No.464 PPAP
ユーザー nebukuro09nebukuro09
提出日時 2016-12-16 01:01:58
言語 D
(dmd 2.105.2)
結果
AC  
実行時間 1,598 ms / 2,000 ms
コード長 958 bytes
コンパイル時間 561 ms
コンパイル使用メモリ 93,972 KB
実行使用メモリ 93,456 KB
最終ジャッジ日時 2023-09-02 23:35:14
合計ジャッジ時間 4,945 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 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 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 62 ms
9,252 KB
testcase_08 AC 42 ms
8,780 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1,598 ms
93,456 KB
testcase_11 AC 242 ms
22,904 KB
testcase_12 AC 382 ms
36,232 KB
testcase_13 AC 4 ms
4,376 KB
testcase_14 AC 1,015 ms
56,788 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,500 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,384 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 3 ms
4,380 KB
testcase_25 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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;


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

  auto LR = new int[][](N);
  auto P3_left = new int[](N);
  int left, right;
  foreach (d; 0..2)
    foreach (i; 0..N) {
      left = i;
      right = i+d;
      while (left >= 0 && right < N && S[left] == S[right]) {
        LR[left] ~= right;
        if (right == N-1)
          P3_left[left] = 1;
        left--;
        right++;
      }
    }

  auto acm = new long[](N+1);
  foreach (i; 0..N)
    acm[i+1] = acm[i] + P3_left[i];

  long ans = 0;
  foreach (r1; LR[0]) {
    if (r1 >= N-3)
      continue;
    foreach (r2; LR[r1+1]) {
      if (r2 >= N-2)
        continue;
      ans += acm[N] - acm[r2+2];
    }
  }
  ans.writeln;
}
0