結果

問題 No.464 PPAP
ユーザー nebukuro09nebukuro09
提出日時 2016-12-16 01:00:01
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 952 bytes
コンパイル時間 824 ms
コンパイル使用メモリ 95,988 KB
実行使用メモリ 95,424 KB
最終ジャッジ日時 2023-09-02 23:35:09
合計ジャッジ時間 5,481 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 65 ms
10,028 KB
testcase_08 AC 44 ms
7,416 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 WA -
testcase_11 AC 240 ms
22,088 KB
testcase_12 AC 399 ms
36,540 KB
testcase_13 AC 4 ms
4,380 KB
testcase_14 AC 1,008 ms
57,564 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 3 ms
4,380 KB
testcase_25 AC 4 ms
4,376 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 int[](N+1);
  foreach (i; 0..N)
    acm[i+1] = acm[i] + P3_left[i];

  int ans;
  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