結果

問題 No.464 PPAP
ユーザー くれちー
提出日時 2016-12-15 23:13:15
言語 C90
(gcc 12.3.0)
結果
TLE  
実行時間 -
コード長 617 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 22,656 KB
実行使用メモリ 10,496 KB
最終ジャッジ日時 2024-11-30 08:58:44
合計ジャッジ時間 16,637 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16 RE * 1 TLE * 5
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:14:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |         scanf("%s", s);
      |         ^~~~~~~~~~~~~~

ソースコード

diff #

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

int iskaibun(char *s, int f, int t) {
	int i;
	for (i = 0; i <= (t - f - 1) / 2; i++) {
		if (s[f + i] != s[t - i]) return 0;
	}
	return 1;
}

int main() {
	char s[5001];
	scanf("%s", s);

	int len = strlen(s);
	int p1, p2, a, cnt = 0;

	for (p1 = 1; p1 <= len - 3; p1++) {
		if (!iskaibun(s, 0, p1 - 1)) continue;
		for (p2 = 1; p2 <= len - 3; p2++) {
			if (!iskaibun(s, p1, p1 + p2 - 1)) continue;
			for (a = 1; a <= len - 3; a++) {
				if (len - (p1 + p2 + a) < 1) continue;
				if (iskaibun(s, p1 + p2 + a, len - 1)) cnt++;
			}
		}
	}

	printf("%d\n", cnt);
	return 0;
}
0