結果
問題 | No.588 空白と回文 |
ユーザー |
![]() |
提出日時 | 2017-11-03 23:01:36 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 786 bytes |
コンパイル時間 | 1,260 ms |
コンパイル使用メモリ | 158,180 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-22 16:16:15 |
合計ジャッジ時間 | 2,092 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
#include <bits/stdc++.h> #define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++) using namespace std; typedef long long ll; string S; int main(void) { cin >> S; ll ans = 0; REP(i, 0, S.length() * 2 - 1) { if(i % 2 == 0) { ll cnt = 1; REP(j, 1, S.length()) { char c1 = i / 2 + j < S.length() ? S[i / 2 + j] : ' '; char c2 = i / 2 - j >= 0 ? S[i / 2 - j] : ' '; if(c1 != ' ' && c1 == c2) cnt += 2; } ans = max(ans, cnt); } else { ll cnt = 0; REP(j, 0, S.length()) { char c1 = i / 2 + j + 1 < S.length() ? S[i / 2 + j + 1] : ' '; char c2 = i / 2 - j >= 0 ? S[i / 2 - j] : ' '; if(c1 != ' ' && c1 == c2) cnt += 2; } ans = max(ans, cnt); } } cout << ans << endl; }