結果
問題 |
No.273 回文分解
|
ユーザー |
![]() |
提出日時 | 2016-08-25 15:23:32 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 699 bytes |
コンパイル時間 | 784 ms |
コンパイル使用メモリ | 67,200 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 13:40:31 |
合計ジャッジ時間 | 1,680 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
#include <iostream> #include <cstring> #include <vector> #include <algorithm> using namespace std; typedef long long ll; #define rep(i,n) for(int i=0;i<(n);i++) int main(void){ string s; cin >> s; vector<int> ans;//見つけた回分の長さを入れていく for (int i = 1; i <= s.size(); ++i){ for (int l = 0; l < s.size(); ++l){ string tmp = s.substr(l, i); string hantenn; for (int j = tmp.size() - 1; j >= 0; --j){ hantenn += tmp[j]; } if(tmp == hantenn){ ans.push_back(tmp.size()); } } } sort(ans.begin(), ans.end()); reverse(ans.begin(), ans.end()); for(auto u : ans){ if(u == s.size()) continue; else{ cout << u << endl; return 0; } } }