結果

問題 No.464 PPAP
ユーザー YamyukiYamyuki
提出日時 2016-12-15 22:26:21
言語 C90
(gcc 12.3.0)
結果
TLE  
実行時間 -
コード長 814 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 22,528 KB
実行使用メモリ 10,496 KB
最終ジャッジ日時 2024-11-30 08:43:46
合計ジャッジ時間 10,687 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19 TLE * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
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