結果
| 問題 |
No.1617 Palindrome Removal
|
| コンテスト | |
| ユーザー |
SSRS
|
| 提出日時 | 2021-07-22 21:40:58 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 2,000 ms |
| コード長 | 621 bytes |
| コンパイル時間 | 2,199 ms |
| コンパイル使用メモリ | 168,644 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-17 16:57:05 |
| 合計ジャッジ時間 | 2,840 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
string S;
cin >> S;
string S2 = S;
reverse(S2.begin(), S2.end());
if (S != S2){
cout << S.size() << endl;
} else if (S.size() == 1){
cout << -1 << endl;
} else {
bool ok = true;
for (int i = 0; i < S.size(); i++){
if (S[i] != S[0]){
ok = false;
}
}
if (ok){
if (S.size() % 2 == 0){
cout << 0 << endl;
} else {
cout << -1 << endl;
}
} else {
if (S.size() == 3){
cout << -1 << endl;
} else {
cout << S.size() - 2 << endl;
}
}
}
}
SSRS