結果
| 問題 |
No.588 空白と回文
|
| コンテスト | |
| ユーザー |
newlife171128
|
| 提出日時 | 2017-12-24 21:51:30 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,039 bytes |
| コンパイル時間 | 606 ms |
| コンパイル使用メモリ | 68,152 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-17 18:37:46 |
| 合計ジャッジ時間 | 5,854 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 WA * 19 |
ソースコード
#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=start; i<=end;i++){
if(s[i] == s[end-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=0;
if(i+k==1){
tmp =1;
}else {
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