結果

問題 No.464 PPAP
ユーザー rickythetarickytheta
提出日時 2016-12-15 22:43:22
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 306 ms / 2,000 ms
コード長 851 bytes
コンパイル時間 1,228 ms
コンパイル使用メモリ 159,416 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-07 15:10:23
合計ジャッジ時間 4,313 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,812 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,944 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 14 ms
6,940 KB
testcase_08 AC 14 ms
6,940 KB
testcase_09 AC 14 ms
6,940 KB
testcase_10 AC 299 ms
6,944 KB
testcase_11 AC 194 ms
6,940 KB
testcase_12 AC 305 ms
6,940 KB
testcase_13 AC 298 ms
6,944 KB
testcase_14 AC 303 ms
6,940 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 1 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 306 ms
6,940 KB
testcase_24 AC 304 ms
6,944 KB
testcase_25 AC 301 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:25:6: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   25 | scanf("%s",s);n=strlen(s);
      | ~~~~~^~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(b)-1;i>=(a);i--)
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
const ll MOD = 1000000009;
#define ADD(a,b) a=((a)+(b))%MOD
#define SUB(a,b) a=((a)-(b)%MOD+MOD)%MOD

int n;
char s[12525];
ll a[12525];
ll b[12525];
ll base=10007;
ll bpow[12525];
bool pal(int l,int r){
ll as = a[r]; SUB(as,a[l]*bpow[r-l]);
ll bs = b[l]; SUB(bs,b[r]*bpow[r-l]);
return as==bs;
}
int main(){
scanf("%s",s);n=strlen(s);
REP(i,n)a[i+1]=(a[i]*base+s[i])%MOD;
FORR(i,0,n)b[i]=(b[i+1]*base+s[i])%MOD;
bpow[0]=1;
REP(i,n)bpow[i+1]=bpow[i]*base%MOD;
ll ans=0;
FOR(i,2,n-2+1){

ll x=0,y=0;
FOR(j,1,i)x+=pal(0,j)*pal(j,i);
FOR(j,i+1,n)y+=pal(j,n);
ans += x*y;


}
cout<<ans<<endl;
return 0;
}
0