結果

問題 No.464 PPAP
ユーザー FF256grhyFF256grhy
提出日時 2016-12-15 22:39:32
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 2,399 bytes
コンパイル時間 1,399 ms
コンパイル使用メモリ 159,704 KB
実行使用メモリ 34,596 KB
最終ジャッジ日時 2024-05-07 15:09:54
合計ジャッジ時間 5,033 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
13,760 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 99 ms
8,940 KB
testcase_08 AC 12 ms
9,396 KB
testcase_09 AC 5 ms
10,112 KB
testcase_10 TLE -
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>
using namespace std;

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(i, v) for(auto i =  v.begin(); i !=  v.end(); ++i)
#define RFOR(i, v) for(auto i = v.rbegin(); i != v.rend(); ++i)

template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T> ostream & operator<<(ostream & os, const vector<T> & v) {
	os << "[";
	FOR(it, v) {
		if(it != v.begin()) { os << ", "; }
		os << *it;
	}
	os << "]";
	return os;
}
template<typename F, typename S> ostream & operator<<(ostream & os, const pair<F, S> & p) {
	os << "<" << p.FI << ", " << p.SE << ">";
	return os;
}

// ---- ----

string s;
LL ans;
bool pd[5000][5000];

/*
bool pd(int l, int r) {
	for(; l < r; l++, r--) {
		if(s[l] != s[r]) { return false; }
	}
	return true;
}
*/

int main() {
	cin >> s;
	
	int len = s.size();
	
	inc(i, len) {
		int l = i, r = i, flag = true;
		while(0 <= l && r < len) {
			if(s[l] != s[r]) { flag = false; }
			pd[l][r] = flag;
			l--; r++;
		}
	}
	inc(i, len) {
		int l = i, r = i + 1, flag = true;
		while(0 <= l && r < len) {
			if(s[l] != s[r]) { flag = false; }
			pd[l][r] = flag;
			l--; r++;
		}
	}
	
	incII(i,     0, len - 4) {
	incII(j, i + 3, len - 1) {
		if(pd[0][i] && pd[j][len - 1]) {
			incII(k, i + 1, j - 2) {
				if(pd[i + 1][k]) { ans++; }
			}
		}
	}
	}
	
	cout << ans << endl;
	
	return 0;
}
0