結果
問題 | No.464 PPAP |
ユーザー | hotpepsi |
提出日時 | 2016-12-23 00:54:16 |
言語 | C++11 (gcc 11.4.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,013 bytes |
コンパイル時間 | 594 ms |
コンパイル使用メモリ | 69,172 KB |
実行使用メモリ | 208,032 KB |
最終ジャッジ日時 | 2024-05-08 11:20:45 |
合計ジャッジ時間 | 5,198 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
10,624 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 4 ms
5,376 KB |
testcase_05 | AC | 3 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 512 ms
50,944 KB |
testcase_08 | AC | 237 ms
34,432 KB |
testcase_09 | AC | 2 ms
5,376 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 | -- | - |
ソースコード
#include <iostream> #include <sstream> #include <algorithm> #include <set> #include <cstring> using namespace std; int main(int argc, char *argv[]) { string s; cin >> s; set<int> p[5001], r[5001]; int len = (int)s.length(); for (int i = 0; i < len; ++i) { for (int j = 0; (i - j) >= 0 && (i + j) < len; ++j) { if (s[i - j] == s[i + j]) { p[i - j].insert(j * 2 + 1); r[i + j + 1].insert(j * 2 + 1); } else { break; } } for (int j = 0; (i - j) >= 0 && (i + j + 1) < len; ++j) { if (s[i - j] == s[i + j + 1]) { p[i - j].insert(j * 2 + 2); r[i + j + 2].insert(j * 2 + 2); } else { break; } } } int cnt = 0; int right[5000] = {}; for (int i = len - 1; i >= 0; --i) { right[i] = cnt; if (r[len].find(len - i) != r[len].end()) { ++cnt; } } int ans = 0; int left[5000] = {}; for (int a : p[0]) { for (int b : p[a]) { left[a + b] += 1; } } for (int i = 0; i < len; ++i) { ans += left[i] * right[i]; } cout << ans << endl; return 0; }