結果

問題 No.464 PPAP
ユーザー tails
提出日時 2016-12-15 22:42:54
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 610 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 20,608 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-30 08:49:27
合計ジャッジ時間 1,065 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:2:1: warning: data definition has no type or storage class
    2 | a[5010];b[5010];
      | ^
main.c:2:1: warning: type defaults to ‘int’ in declaration of ‘a’ [-Wimplicit-int]
main.c:2:9: warning: data definition has no type or storage class
    2 | a[5010];b[5010];
      |         ^
main.c:2:9: warning: type defaults to ‘int’ in declaration of ‘b’ [-Wimplicit-int]
main.c:8:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
    8 | main(i,j,k,l,m){
      | ^~~~
main.c: In function ‘main’:
main.c:8:1: warning: type of ‘i’ defaults to ‘int’ [-Wimplicit-int]
main.c:8:1: warning: type of ‘j’ defaults to ‘int’ [-Wimplicit-int]
main.c:8:1: warning: type of ‘k’ defaults to ‘int’ [-Wimplicit-int]
main.c:8:1: warning: type of ‘l’ defaults to ‘int’ [-Wimplicit-int]
main.c:8:1: warning: type of ‘m’ defaults to ‘int’ [-Wimplicit-int]
main.c:9:9: warning: implicit declaration of function ‘gets’ [-Wimplicit-function-declaration]
    9 |         gets(s);
      |         ^~~~
main.c:10:11: warning: implicit declaration of function ‘strlen’ [-Wimplicit-function-declaration]
   10 |         l=strlen(s);
      |           ^~~~~~
main.c:1:1: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
  +++ |+#include <string.h>
    1 | char s[5010];
main.c:10:11: warning: incompatible implicit declaration of built-in function ‘strlen’ [-Wbuiltin-declaration-mismatch]
   10 |         l=strlen(s);
      |           ^~~~~~
main.c:10:11: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
main.c:50:9: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
   50 |         printf("%lld",r);
      |         ^~~~~~
main.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
  +++ |+#include <stdio.h>
    1 | char s[5010];
main.c:50:9: warning: incompatible implicit declaration of built-in function ‘printf’ [-Wbu

ソースコード

diff #

char s[5010];
a[5010];b[5010];
long long r;

typedef long long H;
H rm=1000000007;

main(i,j,k,l,m){
	gets(s);
	l=strlen(s);
	H r1=0;
	H r2=0;
	H r3=1;
	for(i=0;i<l;++i){
		r1=r1*rm+s[i];
		r2=r2+r3*s[i];
		r3*=rm;
		if(r1==r2){
			H r4=0;
			H r5=0;
			H r6=1;
			for(j=i+1;j<l;++j){
				r4=r4*rm+s[j];
				r5=r5+r6*s[j];
				r6*=rm;
				if(r4==r5){
					++a[j];
				}
			}
		}
	}
	{
		H r7=0;
		H r8=0;
		H r9=1;
		for(j=j-1;j>=0;--j){
			r7=r7*rm+s[j];
			r8=r8+r9*s[j];
			r9*=rm;
			if(r7==r8){
				++b[j];
			}
		}
	}
	m=0;
	for(i=0;i<l;++i){
		m+=a[i];
		r+=m*b[i+2];
	}
	printf("%lld",r);
	return 0;
}
0