結果

問題 No.464 PPAP
ユーザー kuuso1kuuso1
提出日時 2016-12-16 00:16:35
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,163 bytes
コンパイル時間 2,184 ms
コンパイル使用メモリ 112,544 KB
実行使用メモリ 27,684 KB
最終ジャッジ日時 2024-05-07 15:20:06
合計ジャッジ時間 3,707 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
17,536 KB
testcase_01 AC 19 ms
17,536 KB
testcase_02 AC 20 ms
17,280 KB
testcase_03 AC 19 ms
17,408 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 19 ms
17,408 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 20 ms
17,408 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 20 ms
17,536 KB
testcase_16 AC 19 ms
17,408 KB
testcase_17 AC 19 ms
17,536 KB
testcase_18 WA -
testcase_19 AC 19 ms
17,280 KB
testcase_20 AC 19 ms
17,408 KB
testcase_21 WA -
testcase_22 AC 19 ms
17,536 KB
testcase_23 AC 20 ms
17,364 KB
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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;
		}
		
		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 + D1[i] == N) PR[i-D1[i]+1] = 1;
			if(i - D0[i] + 1 == 0) PL[i+D1[i]] = 1;
			if(i + D0[i] == N-1) PR[i-D1[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));}
}
0