結果

問題 No.464 PPAP
ユーザー くれちー
提出日時 2016-12-16 00:05:03
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 940 bytes
コンパイル時間 1,449 ms
コンパイル使用メモリ 166,792 KB
実行使用メモリ 16,840 KB
最終ジャッジ日時 2024-11-30 09:01:21
合計ジャッジ時間 36,240 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 2
other AC * 2 WA * 9 TLE * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pb push_back
using namespace std;

int iskaibun(string s, int f, int t) {
	static vector<pii> tmemo, fmemo;
	sort(all(tmemo));
	sort(all(fmemo));
	if (binary_search(all(tmemo), pii(f, t))) return 1;
	if (binary_search(all(fmemo), pii(f, t))) return 0;

	int i;
	for (i = 0; i <= (t - f - 1) / 2; i++) {
		if (s[f + i] != s[t - i]) {
			fmemo.pb(pii(f, t));
			return 0;
		}
	}
	tmemo.pb(pii(f, t));
	return 1;
}

int main() {
	string s;
	cin >> s;

	int p1, p2, a, cnt = 0;

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

	cout << cnt;
	return 0;
}
0