結果
問題 |
No.599 回文かい
|
ユーザー |
![]() |
提出日時 | 2017-11-25 00:02:16 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,089 bytes |
コンパイル時間 | 1,733 ms |
コンパイル使用メモリ | 163,528 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-27 08:38:48 |
合計ジャッジ時間 | 16,214 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 WA * 2 RE * 16 TLE * 1 |
ソースコード
#include<bits/stdc++.h> using namespace std; string in; vector<string> sq_S; int ans=0; int main(){ cin>>in; int n=in.size(); for(int i=0; i<n/2+!!(n%2);){ for(int j=1; j<n/2; j++){ if(in.substr(i,j)==in.substr(n-i-j,j)){ sq_S.push_back(in.substr(i,j)); //cout<<i<<endl; i+=j; //cout<<i<<endl; //cout<<endl; continue; } //cout<<'a'<<endl; } } int n_sq=sq_S.size(); /*for(int i=0; i<n_sq; i++){ cout<<sq_S.back()<<endl; sq_S.pop_back(); }*/ ans=n_sq; bool flag2=false; for(int i=1; i<n_sq; i++){ int flag=true; for(int j=0; j<i/2+!!(i%2); j++){ //cout<<sq_S[j]<<' '<<sq_S[i-j]<<endl; flag&=(sq_S[j]==sq_S[i-j]); } if(flag){ flag2=true; //cout<<'a'<<endl; ans++; } } if(n_sq==0){ cout<<1<<endl; } else{ cout<<ans-flag2<<endl; } return 0; }