結果
問題 |
No.273 回文分解
|
ユーザー |
|
提出日時 | 2015-10-02 14:31:45 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 714 bytes |
コンパイル時間 | 932 ms |
コンパイル使用メモリ | 71,072 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 12:01:57 |
合計ジャッジ時間 | 1,731 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 28 WA * 4 |
ソースコード
#include <iostream> #include <fstream> #include <vector> #include <map> #include <algorithm> using namespace std; bool is_roop(vector<char> s, int left, int tail) { while (left < tail) { if (s[left] != s[tail]) return false; left++; tail--; } return true; } int main(void) { std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout << std::fixed; vector<char> s; int ans = 1; char c; while (cin >> c) s.push_back(c); int tail = s.size() - 1; for (int left = 0; left < tail; left++) { int right = tail; while (left < right) { if (s[left] == s[right]) { if (is_roop(s, left, right)) ans = max(ans, right - left + 1); } right--; } } cout << ans << endl; }