結果
問題 | No.588 空白と回文 |
ユーザー |
![]() |
提出日時 | 2017-11-03 22:34:19 |
言語 | C++11 (gcc 4.8.5) |
結果 |
AC
|
実行時間 | 5 ms |
コード長 | 887 Byte |
コンパイル時間 | 525 ms |
使用メモリ | 1,532 KB |
最終ジャッジ日時 | 2019-02-01 17:38:19 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
0.txt | AC | 4 ms
1,520 KB |
1.txt | AC | 3 ms
1,520 KB |
2.txt | AC | 3 ms
1,516 KB |
3.txt | AC | 4 ms
1,532 KB |
4.txt | AC | 4 ms
1,516 KB |
5.txt | AC | 4 ms
1,516 KB |
6.txt | AC | 3 ms
1,516 KB |
7.txt | AC | 3 ms
1,516 KB |
8.txt | AC | 3 ms
1,516 KB |
9.txt | AC | 3 ms
1,520 KB |
10.txt | AC | 3 ms
1,516 KB |
11.txt | AC | 3 ms
1,528 KB |
12.txt | AC | 5 ms
1,532 KB |
13.txt | AC | 3 ms
1,516 KB |
14.txt | AC | 3 ms
1,516 KB |
15.txt | AC | 3 ms
1,520 KB |
16.txt | AC | 3 ms
1,516 KB |
17.txt | AC | 5 ms
1,520 KB |
18.txt | AC | 3 ms
1,520 KB |
19.txt | AC | 2 ms
1,520 KB |
20.txt | AC | 4 ms
1,532 KB |
21.txt | AC | 5 ms
1,524 KB |
22.txt | AC | 4 ms
1,532 KB |
23.txt | AC | 4 ms
1,524 KB |
24.txt | AC | 3 ms
1,516 KB |
ソースコード
#include <iostream> #include <vector> #include <map> #include <set> #include <queue> #include <string> #include <iomanip> #include <algorithm> #include <cmath> #include <stdio.h> using namespace std; #define int long long int MOD = 1000000007; signed main() { cin.tie(0); ios::sync_with_stdio(false); string S; cin >> S; int N = S.size(); int res = 0; int t; for (int i = 0; i < N; i++) { t = 0; for (int j = 0; j < N; j++) { if (i + j < N && i - j >= 0) { if (S[i + j] == S[i - j]) { if (j == 0) { t++; } else { t += 2; } } } else { break; } } res = max(res, t); } for (int i = 0; i < N; i++) { t = 0; for (int j = 0; j < N; j++) { if (i + j + 1 < N && i - j >= 0) { if (S[i + j + 1] == S[i - j]) { t += 2; } } else { break; } } res = max(res, t); } cout << res << endl; }