結果

問題 No.464 PPAP
ユーザー YamyukiYamyuki
提出日時 2016-12-15 22:26:21
言語 C90
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 814 bytes
コンパイル時間 197 ms
コンパイル使用メモリ 22,784 KB
実行使用メモリ 13,760 KB
最終ジャッジ日時 2024-05-07 15:06:13
合計ジャッジ時間 3,906 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
13,760 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 0 ms
6,944 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 136 ms
6,944 KB
testcase_08 AC 67 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:19:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   19 |         scanf("%s",str);
      |         ^~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
#include<string.h>

int check(char *str,int s,int e){
	int w,i;
	w=(e-s+1)/2;
	for(i=0;i<w;i++){
		if(str[s+i]!=str[e-i]) return 0;
	}
	return 1;
}

long num[4999];

int main(){
	char str[5001];
	int n,i,j,k;
	long c=0;
	scanf("%s",str);
	n=strlen(str);
	/*for(i=0;i<n-3;i++){
		if(check(str,0,i)){
			for(j=i+1;j<n-2;j++){
				if(check(str,i+1,j)){
					for(k=n-1;k>j+1;k--){
						if(check(str,k,n-1)){
							c++;
						}
					}
				}
			}
		}
	}*/
	memset(num,-1,sizeof(num));
	for(i=n-1;i>2;i--){
		if(check(str,i,n-1)){
			for(j=i-1;j>1;j--){
				if(num[j]<0){
					num[j]=0;
					for(k=j-1;k>0;k--){
						if(check(str,k,j-1)){
							if(check(str,0,k-1)){
								num[j]++;
								c++;
							}
						}
					}
				}else{
					c+=num[j];
				}
			}
		}
	}
	printf("%ld\n",c);
	return 0;
}
0