結果
問題 | No.464 PPAP |
ユーザー |
![]() |
提出日時 | 2020-06-28 13:21:22 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,231 bytes |
コンパイル時間 | 1,007 ms |
コンパイル使用メモリ | 90,048 KB |
実行使用メモリ | 141,952 KB |
最終ジャッジ日時 | 2024-07-07 13:35:39 |
合計ジャッジ時間 | 5,771 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 TLE * 1 |
ソースコード
#include <iostream>#include <algorithm>#include <iomanip>#include <vector>#include <queue>#include <set>#include <map>using namespace std;typedef long long ll;vector<int> v[5000], u[5000];int main(){ios::sync_with_stdio(false);cin.tie(0);cout << setprecision(10) << fixed;string s;cin >> s;int n = s.size();for(int i = 0; i < n; i++){for(int j = 0; i-j >= 0 && i+j < n; j++){int l = i-j, r = i+j;if(s[l] != s[r]) break;v[l].push_back(r);u[r].push_back(l);}}for(int i = 0; i < n-1; i++){for(int j = 0; i-j >= 0 && i+j+1 < n; j++){int l = i-j, r = i+j+1;if(s[l] != s[r]) break;v[l].push_back(r);u[r].push_back(l);}}for(int i = 0; i < n; i++) {sort(v[i].begin(), v[i].end());sort(u[i].begin(), u[i].end());}ll ans = 0;for(int l : v[0]){for(int r : u[n-1]){if(r < l) continue;int l1 = l+1;// r1 < r-1auto p = upper_bound(v[l1].begin(), v[l1].end(), r-2);ans += p-v[l1].begin();}}cout << ans << endl;}