結果
問題 | No.273 回文分解 |
ユーザー |
|
提出日時 | 2015-12-16 17:34:33 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 538 bytes |
コンパイル時間 | 1,246 ms |
コンパイル使用メモリ | 159,828 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-25 13:33:32 |
合計ジャッジ時間 | 2,248 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for(int(i)=0;(i)<(n);++(i)) #define in(T,V) T V;cin>>V; int main(){ in(string,s); int n = s.length(), m = n; int res = 1; auto f = [&s](int i){ return i%2?' ':s[i/2]; }; n = n * 2 - 1; REP(i,n){ REP(j,n){ if(i<j||i+j>=n)break; if(f(i-j) == f(i+j)){ int v = i%2 ? (j+1)/2*2 : 1+j/2*2; if(v < m) res = max(res, v); } else break; } } cout << res << endl; }