結果
| 問題 |
No.1617 Palindrome Removal
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2024-03-15 11:49:49 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 602 bytes |
| コンパイル時間 | 1,926 ms |
| コンパイル使用メモリ | 193,836 KB |
| 最終ジャッジ日時 | 2025-02-20 04:30:29 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 18 WA * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
//aabb->N
//aaabaaa -> N-2
//aaabbaaa -> N-2
//aaa -> -1
//aaaa ->0
string S;
cin >> S;
int N = S.size();
for (int i=0; i<N/2; i++){
if (S[i] != S[N-1-i]){
cout << N << endl;
return 0;
}
}
for (int i=0; i<N; i++){
if (S[i] != S[0]){
cout << N-2 << endl;
return 0;
}
}
cout << (N % 2 == 1 ? -1 : 0) << endl;
return 0;
}
srjywrdnprkt