結果

問題 No.464 PPAP
ユーザー くれちーくれちー
提出日時 2016-12-16 00:05:03
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 940 bytes
コンパイル時間 1,547 ms
コンパイル使用メモリ 165,648 KB
実行使用メモリ 10,016 KB
最終ジャッジ日時 2024-05-07 15:18:35
合計ジャッジ時間 4,753 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
10,016 KB
testcase_01 WA -
testcase_02 AC 1 ms
5,376 KB
testcase_03 WA -
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

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