結果
| 問題 |
No.273 回文分解
|
| コンテスト | |
| ユーザー |
kyo1
|
| 提出日時 | 2020-12-12 08:23:40 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 546 bytes |
| コンパイル時間 | 2,527 ms |
| コンパイル使用メモリ | 193,452 KB |
| 最終ジャッジ日時 | 2025-01-16 22:54:33 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
bool is_palindrome(string s) {
for (size_t i = 0; i < s.size() / 2; i++) {
if (s[i] != s[s.size() - i - 1]) return false;
}
return true;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
string S;
cin >> S;
int res = 0;
for (int i = 0; i < (int)S.size(); i++) {
for (int j = 1; j < (int)S.size() - i + 1; j++) {
auto T = S.substr(i, j);
if (is_palindrome(T) && j != (int)S.size()) res = max(res, j);
}
}
cout << res << '\n';
return 0;
}
kyo1