結果
問題 |
No.464 PPAP
|
ユーザー |
![]() |
提出日時 | 2018-04-18 15:37:34 |
言語 | C90 (gcc 12.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 577 bytes |
コンパイル時間 | 667 ms |
コンパイル使用メモリ | 22,272 KB |
実行使用メモリ | 13,756 KB |
最終ジャッジ日時 | 2024-06-27 04:30:02 |
合計ジャッジ時間 | 4,356 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 3 TLE * 1 -- * 18 |
コンパイルメッセージ
main.c: In function ‘run’: main.c:15:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | scanf("%s",s); | ^~~~~~~~~~~~~
ソースコード
#include<stdio.h> #include<stdlib.h> int isPalindrome(char *s,int l,int r){ int i=0; while(l+i<r-1-i){ if(s[l+i]!=s[r-1-i]) return 0; i++; } return 1; } void run(void){ char s[5001]; scanf("%s",s); int n=0; while(s[n]!='\0') n++; int cnt=0; int i; for(i=1;i<n;i++){ if(!isPalindrome(s,0,i)) continue; int j; for(j=i+1;j<n;j++){ if(!isPalindrome(s,i,j)) continue; int k; for(k=n-1;k>j;k--){ if(isPalindrome(s,k,n)) cnt++; } } } printf("%d\n",cnt); return; } int main(void){ run(); return 0; }