結果
| 問題 |
No.588 空白と回文
|
| コンテスト | |
| ユーザー |
newlife171128
|
| 提出日時 | 2017-12-24 21:53:15 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 645 ms / 2,000 ms |
| コード長 | 986 bytes |
| コンパイル時間 | 710 ms |
| コンパイル使用メモリ | 70,464 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-17 18:38:00 |
| 合計ジャッジ時間 | 5,819 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
#include <stack>
using namespace std;
string s;
int func(int start,int end){
vector<char> p;
for(int i=start; i<=end; i++){
p.push_back(s[i]);
}
int count=0;
for(int i=0; i<p.size();i++){
if(p[i] == p[p.size()-1-i]){
count++;
}
}
return count;
}
int main() {
cin >> s;
int left_side = 0;
int right_side = 0;
int ans = 1;
bool judge=false;
/* cout << s.length() << endl;*/
for (int k = 0; k < s.length() - 3; k++) {
for (int i = 1; i < s.length() - 1-k; i++) {
judge =false;
left_side = i;
right_side = i+k;
int tmp = func(left_side,right_side);
while (left_side != 0 && right_side != s.length() - 1) {
if (s[--left_side] == s[++right_side]) {
tmp += 2;
judge =true;
}
}
if(judge)
ans = max(ans, tmp);
}
}
if (ans == 1) {
cout << ans << endl;
} else {
cout << ans << endl;
}
return 0;
}
newlife171128