結果
問題 |
No.464 PPAP
|
ユーザー |
|
提出日時 | 2025-07-28 18:10:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 46 ms / 2,000 ms |
コード長 | 1,751 bytes |
コンパイル時間 | 1,754 ms |
コンパイル使用メモリ | 194,240 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-07-28 18:10:27 |
合計ジャッジ時間 | 3,297 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:57:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 57 | scanf("%s", s + 1); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h> #define ls(k) k << 1 #define rs(k) k << 1 | 1 #define fi first #define se second #define add(x, y) ((x + y >= mod) ? (x + y - mod) : (x + y)) #define dec(x, y) ((x - y < 0) ? (x - y + mod) : (x - y)) #define popcnt(x) __builtin_popcount(x) #define open(s1, s2) freopen(s1, "r", stdin), freopen(s2, "w", stdout); using namespace std; typedef __int128 __; typedef long double lb; typedef double db; typedef unsigned long long ull; typedef long long ll; bool Begin; const int N = 5050; const ull base = 127; inline ll read(){ ll x = 0, f = 1; char c = getchar(); while(c < '0' || c > '9'){ if(c == '-') f = -1; c = getchar(); } while(c >= '0' && c <= '9'){ x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); } return x * f; } inline void write(ll x){ if(x < 0){ putchar('-'); x = -x; } if(x > 9) write(x / 10); putchar(x % 10 + '0'); } ll ans; int n; int a[N]; ull poww[N], p[2][N]; char s[N], t[N]; inline ull get(int l, int r, bool f){ return p[f][r] - poww[r - l + 1] * p[f][l - 1]; } inline bool check(int l, int r){ return get(l, r, 0) == get(n - r + 1, n - l + 1, 1); } bool End; int main(){ //open("par.in", "par.out"); poww[0] = 1; scanf("%s", s + 1); n = strlen(s + 1); for(int i = 1; i <= n; ++i){ t[i] = s[n - i + 1]; poww[i] = base * poww[i - 1]; p[0][i] = p[0][i - 1] * base + s[i]; p[1][i] = p[1][i - 1] * base + t[i]; } for(int i = 1; i <= n; ++i) for(int j = 1; j < i; ++j) if(check(1, j) && check(j + 1, i)) ++a[i]; for(int l = 2; l < n; ++l) for(int r = l; r < n; ++r) if(check(r + 1, n)) ans += a[l - 1]; write(ans); //cerr << '\n' << abs(&Begin - &End) / 1048576 << "MB"; return 0; }