結果
| 問題 |
No.464 PPAP
|
| コンテスト | |
| ユーザー |
kuuso1
|
| 提出日時 | 2016-12-16 00:31:47 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,266 bytes |
| コンパイル時間 | 1,063 ms |
| コンパイル使用メモリ | 107,520 KB |
| 実行使用メモリ | 17,792 KB |
| 最終ジャッジ日時 | 2024-11-30 09:09:40 |
| 合計ジャッジ時間 | 2,775 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 WA * 2 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class TEST{
static void Main(){
Sol mySol =new Sol();
mySol.Solve();
}
}
class Sol{
public void Solve(){
int N = S.Length;
int[] D1 = new int[N];
for(int i=0;i<N;i++){
int r = 0;
while(true){
if(i-r<0)break;
if(i+r>=N)break;
if(S[i-r] != S[i+r])break;
r++;
}
D1[i] = r;
}
int[] D0 = new int[N];
for(int i=0;i<N;i++){
int r = 0;
while(true){
if(i-r<0)break;
if(i+r+1>=N)break;
if(S[i-r] != S[i+r+1])break;
r++;
}
D0[i] = r;
}
//Console.WriteLine(String.Join(" ",D1));
//Console.WriteLine(String.Join(" ",D0));
int[] PL = new int[N];
int[] PR = new int[N];
for(int i=0;i<N;i++){
if(i - D1[i] + 1 == 0) PL[i+D1[i]-1] = 1;
if(i - D0[i] + 1 == 0) PL[i+D1[i]] = 1;
if(i + D1[i] == N) PR[i-D1[i]+1] = 1;
if(i + D0[i] == N-1 && i<N-1) PR[i-D0[i]+1] = 1;
}
//Console.WriteLine(String.Join(" ",PL));
//Console.WriteLine(String.Join(" ",PR));
long[] PP = new long[N];
for(int i=0;i<N;i++){
for(int r=0;r<D1[i];r++){
if(i-r-1<0)break;
PP[i+r] += PL[i-r-1];
}
for(int r=0;r<D0[i];r++){
if(i-r-1<0)break;
PP[i+r+1] += PL[i-r-1];
}
}
//Console.WriteLine(String.Join(" ",PP));
long[] PPA = new long[N];
PPA[0] = 0;
for(int i=1;i<N;i++){
PPA[i] = PP[i] + PPA[i-1];
}
long ans = 0;
for(int i=N-1;i>=0;i--){
if(PR[i] == 0) continue;
if(i-2 < 0) break;
ans += PPA[i-2];
}
Console.WriteLine(ans);
}
String S;
public Sol(){
S = rs();
}
static String rs(){return Console.ReadLine();}
static int ri(){return int.Parse(Console.ReadLine());}
static long rl(){return long.Parse(Console.ReadLine());}
static double rd(){return double.Parse(Console.ReadLine());}
static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}
kuuso1