結果
問題 | No.464 PPAP |
ユーザー |
|
提出日時 | 2016-12-16 01:01:58 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 1,578 ms / 2,000 ms |
コード長 | 958 bytes |
コンパイル時間 | 684 ms |
コンパイル使用メモリ | 111,052 KB |
実行使用メモリ | 92,556 KB |
最終ジャッジ日時 | 2024-06-12 05:38:08 |
合計ジャッジ時間 | 4,735 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 |
ソースコード
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; }